Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <YSI\y_ini>
- //#include <dini>
- #pragma tabsize 0
- #define PATH "/MJDM/%s.ini"
- new InDM[MAX_PLAYERS];
- new Float:x1,Float:y1,Float:z1;
- new weapdat[13][2];
- new cn;
- new skin;
- //new kills[MAX_PLAYERS];
- //new deaths[MAX_PLAYERS];
- new Float:Spawns[][]= {
- {-2491.8706,-237.2221,39.3019,295.0867},
- {-2482.0308,-283.6506,40.5421,180.7190},
- {-2444.0479,-271.4679,35.6237,258.4264},
- {-2490.9055,-298.6101,35.8574,172.5956},
- {-2525.5771,-313.8878,39.0723,327.6012},
- {-2554.4729,-291.1451,25.9594,118.0751}
- };
- new weaps[][] = {
- {22},
- {23},
- {24},
- {25},
- {26},
- {27},
- {28},
- {29},
- {30},
- {31},
- {32}
- };
- enum pInfo
- {
- pKills,
- pDeaths
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Kills", PlayerInfo[playerid][pKills]);
- INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128], pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName,sizeof(pName));
- format(string,sizeof(string),PATH,pName);
- return string;
- }
- #define COLOR_RED 0xFF3300
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" DM[Minigame] by DuskXtremeX");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //SetVehicleParamsEx(playerid,0,lights,alarm,doors,bonnet,boot,objective);
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s",.bExtra =true, .extra =playerid);
- }
- else if(!fexist(UserPath(playerid)))
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerInfo");
- INI_WriteInt(File,"Kills",0);
- INI_WriteInt(File,"Deaths",0);
- INI_Close(File);
- }
- InDM[playerid] =0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(InDM[playerid] ==1)
- {
- cn--;
- InDM[playerid] =0;
- }
- CheckWin();
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- GivePlayerWeapon(playerid,26,300);
- GivePlayerWeapon(playerid,32,300);
- GivePlayerWeapon(playerid,34,100);
- GivePlayerWeapon(playerid,27,50);
- GetPlayerSkin(skin);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(InDM[playerid] ==1)
- {
- InDM[playerid] =0;
- cn--;
- new str[100];
- new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME];
- GetPlayerName(killerid,kName,MAX_PLAYER_NAME);
- GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
- format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName);
- SendClientMessageToAll(-1, str);
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerInfo");
- INI_WriteInt(File,"Kills",PlayerInfo[killerid][pKills]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- new CurKills = PlayerInfo[killerid][pKills];
- new CurDies = PlayerInfo[playerid][pDeaths];
- PlayerInfo[playerid][pDeaths] = CurDies + 1;
- PlayerInfo[killerid][pKills] = CurKills +1;
- INI_Close(File);
- CheckCrime(playerid, killerid);
- CheckWin();
- }
- return 1;
- }
- CMD:increase(playerid,params[])
- {
- PlayerInfo[playerid][pDeaths]++;
- PlayerInfo[playerid][pKills]++;
- printf("Deaths: %d Kills : %d",PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills]);
- return 1;
- }
- COMMAND:deathmatch(playerid, params[])
- {
- if(InDM[playerid] ==0)
- {
- InDM[playerid] =1;
- cn++;
- new p;
- for(p=0;p<13;p++)
- {
- GetPlayerWeaponData(playerid,p,weapdat[p][0],weapdat[p][1]);
- }
- ResetPlayerWeapons(playerid);
- new string[100];
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
- format(string, sizeof(string), "%s(%d) has joined DM",pName,playerid);
- GetPlayerPos(playerid, x1, y1, z1);
- new Random = random(sizeof(Spawns));
- SetPlayerPos(playerid, Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
- SetPlayerFacingAngle(playerid, Spawns[Random][3]);
- new randomskin = random(50);
- SetPlayerSkin(playerid, randomskin);
- new Random1 = random(sizeof(weaps));
- GivePlayerWeapon(playerid, weaps[Random1][0], 150);
- }
- else if(InDM[playerid] ==1)
- {
- SendClientMessage(playerid, COLOR_RED,"You're already in DM");
- }
- return 1;
- }
- COMMAND:leavedm(playerid,params[])
- {
- if(InDM[playerid] ==0)
- {
- SendClientMessage(playerid, COLOR_RED, "You're not in DM");
- }
- else if(InDM[playerid] ==1)
- {
- ResetPlayer(playerid);
- }
- return 1;
- }
- forward CheckWin();
- public CheckWin()
- {
- if(cn ==1)
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(InDM[i] ==1)
- {
- new string[128], winner[MAX_PLAYER_NAME];
- GetPlayerName(i,winner,MAX_PLAYER_NAME);
- format(string,sizeof(string),"~g~%s(%d) ~y~Has won the DeathMatch[Minigame]",winner,i);
- GivePlayerMoney(i, GetPlayerMoney(i) + 10000);
- SetPlayerScore(i, GetPlayerScore(i) + 2);
- SendClientMessageToAll(-1, string);
- for(new p=0;p<MAX_PLAYERS;p++) // Here 'p' is to loop trhrough all players
- {
- if(InDM[p] ==1) // If the player is in DM, It shows the message which is stored in the above string 'string'
- {
- GameTextForPlayer(p,string,3000,4);
- }
- }
- ResetPlayerWeapons(i);
- GetPlayerPos(i, x1, y1, z1);
- new Random = random(sizeof(Spawns));
- SetPlayerPos(i, Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
- SetPlayerFacingAngle(i, Spawns[Random][3]);
- new randomskin = random(50);
- SetPlayerSkin(i, randomskin);
- new Random1 = random(sizeof(weaps));
- GivePlayerWeapon(i, weaps[Random1][0], 150);
- break;
- }
- }
- }
- return 1;
- }
- forward ResetPlayer(playerid);
- public ResetPlayer(playerid)
- {
- InDM[playerid] =0;
- cn--;
- //SetPlayerPos(playerid,x1,y1,z1);
- SetPlayerSkin(playerid,skin);
- ResetPlayerWeapons(playerid);
- for(new p=0;p<13;p++)
- {
- GivePlayerWeapon(playerid,weapdat[p][0],weapdat[p][1]);
- }
- return 1;
- }
- forward CheckCrime(playerid, killerid);
- public CheckCrime(playerid, killerid)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerInfo");
- INI_WriteInt(File,"Kills",PlayerInfo[killerid][pKills]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- INI_Close(File);
- PlayerInfo[killerid][pKills]++;
- PlayerInfo[playerid][pDeaths]++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement