Advertisement
DuskXtremeX

SAMP DEATHMATCH v1.0.2[In Dev #2]

Jul 29th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <YSI\y_ini>
  6. //#include <dini>
  7. #pragma tabsize 0
  8. #define PATH "/MJDM/%s.ini"
  9.  
  10. new InDM[MAX_PLAYERS];
  11. new Float:x1,Float:y1,Float:z1;
  12. new weapdat[13][2];
  13. new cn;
  14. new skin;
  15. //new kills[MAX_PLAYERS];
  16. //new deaths[MAX_PLAYERS];
  17. new Float:Spawns[][]= {
  18.    {-2491.8706,-237.2221,39.3019,295.0867},
  19.    {-2482.0308,-283.6506,40.5421,180.7190},
  20.    {-2444.0479,-271.4679,35.6237,258.4264},
  21.    {-2490.9055,-298.6101,35.8574,172.5956},
  22.    {-2525.5771,-313.8878,39.0723,327.6012},
  23.    {-2554.4729,-291.1451,25.9594,118.0751}
  24. };
  25.  
  26. new weaps[][] = {
  27.    {22},
  28.    {23},
  29.    {24},
  30.    {25},
  31.    {26},
  32.    {27},
  33.    {28},
  34.    {29},
  35.    {30},
  36.    {31},
  37.    {32}
  38. };
  39.  
  40. enum pInfo
  41. {
  42.   pKills,
  43.   pDeaths
  44. }
  45.  
  46. new PlayerInfo[MAX_PLAYERS][pInfo];
  47.  
  48. forward LoadUser_data(playerid,name[],value[]);
  49. public LoadUser_data(playerid,name[],value[])
  50. {
  51.   INI_Int("Kills", PlayerInfo[playerid][pKills]);
  52.   INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  53.   return 1;
  54. }
  55.  
  56. stock UserPath(playerid)
  57. {
  58.   new string[128], pName[MAX_PLAYER_NAME];
  59.   GetPlayerName(playerid, pName,sizeof(pName));
  60.   format(string,sizeof(string),PATH,pName);
  61.   return string;
  62. }
  63.  
  64. #define COLOR_RED 0xFF3300
  65.  
  66. public OnFilterScriptInit()
  67. {
  68.     print("\n--------------------------------------");
  69.     print(" DM[Minigame] by DuskXtremeX");
  70.     print("--------------------------------------\n");
  71.     return 1;
  72. }
  73.  
  74. public OnFilterScriptExit()
  75. {
  76.     return 1;
  77. }
  78.  
  79.  
  80. public OnPlayerRequestClass(playerid, classid)
  81. {
  82.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  83.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  84.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerConnect(playerid)
  89. {
  90.     //SetVehicleParamsEx(playerid,0,lights,alarm,doors,bonnet,boot,objective);
  91.     if(fexist(UserPath(playerid)))
  92.     {
  93.      INI_ParseFile(UserPath(playerid), "LoadUser_%s",.bExtra =true, .extra =playerid);
  94.     }
  95.     else if(!fexist(UserPath(playerid)))
  96.     {
  97.       new INI:File = INI_Open(UserPath(playerid));
  98.       INI_SetTag(File,"PlayerInfo");
  99.       INI_WriteInt(File,"Kills",0);
  100.       INI_WriteInt(File,"Deaths",0);
  101.       INI_Close(File);
  102.     }
  103.  
  104.     InDM[playerid] =0;
  105.     return 1;
  106. }
  107.  
  108. public OnPlayerDisconnect(playerid, reason)
  109. {
  110.     if(InDM[playerid] ==1)
  111.     {
  112.       cn--;
  113.       InDM[playerid] =0;
  114.     }
  115.     CheckWin();
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerSpawn(playerid)
  120. {
  121.  
  122.     GivePlayerWeapon(playerid,26,300);
  123.     GivePlayerWeapon(playerid,32,300);
  124.     GivePlayerWeapon(playerid,34,100);
  125.     GivePlayerWeapon(playerid,27,50);
  126.     GetPlayerSkin(skin);
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerDeath(playerid, killerid, reason)
  131. {
  132.     if(InDM[playerid] ==1)
  133.     {
  134.       InDM[playerid] =0;
  135.       cn--;
  136.       new str[100];
  137.       new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME];
  138.       GetPlayerName(killerid,kName,MAX_PLAYER_NAME);
  139.       GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  140.       format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName);
  141.       SendClientMessageToAll(-1, str);
  142.       new INI:File = INI_Open(UserPath(playerid));
  143.       INI_SetTag(File,"PlayerInfo");
  144.       INI_WriteInt(File,"Kills",PlayerInfo[killerid][pKills]);
  145.       INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  146.       new CurKills = PlayerInfo[killerid][pKills];
  147.       new CurDies = PlayerInfo[playerid][pDeaths];
  148.       PlayerInfo[playerid][pDeaths] = CurDies + 1;
  149.       PlayerInfo[killerid][pKills] = CurKills +1;
  150.       INI_Close(File);
  151.       CheckCrime(playerid, killerid);
  152.       CheckWin();
  153.     }
  154.     return 1;
  155. }
  156. CMD:increase(playerid,params[])
  157. {
  158.   PlayerInfo[playerid][pDeaths]++;
  159.   PlayerInfo[playerid][pKills]++;
  160.   printf("Deaths: %d Kills : %d",PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills]);
  161.   return 1;
  162. }
  163. COMMAND:deathmatch(playerid, params[])
  164. {
  165.  
  166.    if(InDM[playerid] ==0)
  167.       {
  168.         InDM[playerid] =1;
  169.         cn++;
  170.         new p;
  171.         for(p=0;p<13;p++)
  172.         {
  173.          GetPlayerWeaponData(playerid,p,weapdat[p][0],weapdat[p][1]);
  174.         }
  175.         ResetPlayerWeapons(playerid);
  176.         new string[100];
  177.         new pName[MAX_PLAYER_NAME];
  178.         GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  179.         format(string, sizeof(string), "%s(%d) has joined DM",pName,playerid);
  180.         GetPlayerPos(playerid, x1, y1, z1);
  181.         new Random = random(sizeof(Spawns));
  182.         SetPlayerPos(playerid, Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
  183.         SetPlayerFacingAngle(playerid, Spawns[Random][3]);
  184.         new randomskin = random(50);
  185.         SetPlayerSkin(playerid, randomskin);
  186.         new Random1 = random(sizeof(weaps));
  187.         GivePlayerWeapon(playerid, weaps[Random1][0], 150);
  188.       }
  189.    else if(InDM[playerid] ==1)
  190.    {
  191.      SendClientMessage(playerid, COLOR_RED,"You're already in DM");
  192.    }
  193.    return 1;
  194.     }
  195.  
  196.  
  197. COMMAND:leavedm(playerid,params[])
  198. {
  199.    if(InDM[playerid] ==0)
  200.    {
  201.       SendClientMessage(playerid, COLOR_RED, "You're not in DM");
  202.    }
  203.    else if(InDM[playerid] ==1)
  204.    {
  205.      ResetPlayer(playerid);
  206.    }
  207.    return 1;
  208. }
  209. forward CheckWin();
  210. public CheckWin()
  211. {
  212.   if(cn ==1)
  213.   {
  214.     for(new i=0;i<MAX_PLAYERS;i++)
  215.     {
  216.       if(InDM[i] ==1)
  217.       {
  218.         new string[128], winner[MAX_PLAYER_NAME];
  219.         GetPlayerName(i,winner,MAX_PLAYER_NAME);
  220.         format(string,sizeof(string),"~g~%s(%d) ~y~Has won the DeathMatch[Minigame]",winner,i);
  221.         GivePlayerMoney(i, GetPlayerMoney(i) + 10000);
  222.         SetPlayerScore(i, GetPlayerScore(i) + 2);
  223.         SendClientMessageToAll(-1, string);
  224.         for(new p=0;p<MAX_PLAYERS;p++) // Here 'p' is to loop trhrough all players
  225.         {
  226.           if(InDM[p] ==1)              // If the player is in DM, It shows the message which is stored in the above string 'string'
  227.           {
  228.             GameTextForPlayer(p,string,3000,4);
  229.           }
  230.         }
  231.         ResetPlayerWeapons(i);
  232.         GetPlayerPos(i, x1, y1, z1);
  233.         new Random = random(sizeof(Spawns));
  234.         SetPlayerPos(i, Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
  235.         SetPlayerFacingAngle(i, Spawns[Random][3]);
  236.         new randomskin = random(50);
  237.         SetPlayerSkin(i, randomskin);
  238.         new Random1 = random(sizeof(weaps));
  239.         GivePlayerWeapon(i, weaps[Random1][0], 150);
  240.         break;
  241.       }
  242.     }
  243.  
  244.   }
  245.   return 1;
  246. }
  247.  
  248. forward ResetPlayer(playerid);
  249. public ResetPlayer(playerid)
  250. {
  251.   InDM[playerid] =0;
  252.   cn--;
  253.   //SetPlayerPos(playerid,x1,y1,z1);
  254.   SetPlayerSkin(playerid,skin);
  255.   ResetPlayerWeapons(playerid);
  256.   for(new p=0;p<13;p++)
  257.   {
  258.     GivePlayerWeapon(playerid,weapdat[p][0],weapdat[p][1]);
  259.   }
  260.   return 1;
  261. }
  262.  
  263. forward CheckCrime(playerid, killerid);
  264. public CheckCrime(playerid, killerid)
  265. {
  266.       new INI:File = INI_Open(UserPath(playerid));
  267.       INI_SetTag(File,"PlayerInfo");
  268.       INI_WriteInt(File,"Kills",PlayerInfo[killerid][pKills]);
  269.       INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  270.       INI_Close(File);
  271.       PlayerInfo[killerid][pKills]++;
  272.       PlayerInfo[playerid][pDeaths]++;
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement