Advertisement
Guest User

Mowgli

a guest
Nov 15th, 2009
1,442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.42 KB | None | 0 0
  1. //Please dont remove these credits (For me,DArren Reeder (AKA Mowgli on forums)
  2.  
  3. //THis is v0.2 where i added a medic pack system, pretty simple just because people sort of requested it...
  4.  
  5. #include <a_samp>
  6. #include <utils>
  7.  
  8. #define FILTERSCRIPT
  9.  
  10. #define COLOR_LIGHTBLUE 0x33CCFFAA
  11. #define COLOR_RED 0xAA3333AA
  12. #define COLOR_LIGHTRED 0xFF6347AA
  13. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  14.  
  15. forward CheckHealth(playerid);
  16. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  17. forward beingrevived(giveplayerid,playerid);
  18. forward reviveddone(giveplayerid,playerid);
  19.  
  20. new FirstTime[MAX_PLAYERS];
  21. new OnFloor[MAX_PLAYERS];
  22. new revid[MAX_PLAYERS];
  23. new medicpack[MAX_PLAYERS];
  24.  
  25. #if defined FILTERSCRIPT
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     print("\n--------------------------------------");
  30.     print(" Revive System v0.2 by Darren Reeder / Mowgli");
  31.     print("--------------------------------------\n");
  32.     return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37.     return 1;
  38. }
  39.  
  40.  
  41. #endif
  42.  
  43. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  44. {
  45.    new Float:oldposx, Float:oldposy, Float:oldposz;
  46.    new Float:tempposx, Float:tempposy, Float:tempposz;
  47.    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  48.    tempposx = (oldposx -x);
  49.    tempposy = (oldposy -y);
  50.    tempposz = (oldposz -z);
  51.    //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  52.    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  53.    {
  54.        return 1;
  55.    }
  56.    return 0;
  57. }
  58.  
  59. public CheckHealth(playerid)
  60. {
  61.     new Float:health;
  62.     GetPlayerHealth(playerid,health);
  63.  
  64.     if(health >= 1 && health <= 10)
  65.     {
  66.         if(FirstTime[playerid] == 0)
  67.         {
  68.             SendClientMessage(playerid,COLOR_RED,"You are Dieing, you need to be revived or you can /suicide");
  69.         }
  70.         TogglePlayerControllable(playerid,0);
  71.         FirstTime[playerid] = 1;
  72.         OnFloor[playerid] = 1;
  73.         ApplyAnimation(playerid,"CRACK","crckdeth2",4.0,0,0,0,1,1);
  74.     }
  75.  
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerConnect(playerid)
  80. {
  81.     SetTimerEx("CheckHealth",100,1,"d",playerid);
  82.     FirstTime[playerid] = 0; OnFloor[playerid] = 0; revid[playerid] = 0; medicpack[playerid] = 1;
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerDisconnect(playerid, reason)
  87. {
  88.     FirstTime[playerid] = 0; OnFloor[playerid] = 0; revid[playerid] = 0;
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerSpawn(playerid)
  93. {
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerDeath(playerid, killerid, reason)
  98. {
  99.     if(OnFloor[playerid] == 1)
  100.     {
  101.     OnFloor[playerid] = 0;
  102.     TogglePlayerControllable(playerid,1);
  103.     }
  104.  
  105.     return 1;
  106. }
  107.  
  108. public OnVehicleSpawn(vehicleid)
  109. {
  110.     return 1;
  111. }
  112.  
  113. public OnVehicleDeath(vehicleid, killerid)
  114. {
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerText(playerid, text[])
  119. {
  120.     return 1;
  121. }
  122.  
  123. public OnPlayerCommandText(playerid, cmdtext[])
  124. {
  125.     dcmd(revive,6,cmdtext);
  126.     if (strcmp("/revivehelp", cmdtext, true, 10) == 0)
  127.     {
  128.         SendClientMessage(playerid,COLOR_LIGHTBLUE,"/buymedicpack to buy a medic pack for 5,000 dollars");
  129.         SendClientMessage(playerid,COLOR_LIGHTBLUE,"When someones Health bar has reached to 10 they then have 5 minutes");
  130.         SendClientMessage(playerid,COLOR_LIGHTBLUE,"to either /suicide or be /revive'd by somone. If you are revived, your");
  131.         SendClientMessage(playerid,COLOR_LIGHTBLUE,"health is set back to 50.");
  132.         SendClientMessage(playerid,COLOR_LIGHTBLUE,"**Revive System v0.2 created by Mowgli**");
  133.         return 1;
  134.     }
  135.     if (strcmp("/buymedicpack", cmdtext, true, 10) == 0)
  136.     {
  137.         if(GetPlayerMoney(playerid) <= 4999) return SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot afford a Medic Pack (5,000)");
  138.         else if(medicpack[playerid] == 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"You already have a medic pack!! stupid...");
  139.         else { medicpack[playerid] = 1; SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a medic pack for 5000Dollars.."); GivePlayerMoney(playerid,-5000); }
  140.         return 1;
  141.     }
  142.     if (strcmp("/suicide", cmdtext, true, 10) == 0)
  143.     {
  144.         if(OnFloor[playerid] == 1)
  145.         {
  146.             SendClientMessage(playerid,COLOR_LIGHTRED,"You close your eyes and slowly Grab your knife and Stab your heart.");
  147.             SetPlayerHealth(playerid,0);
  148.             FirstTime[playerid] = 0;
  149.             OnFloor[playerid] = 0;
  150.             return 1;
  151.         }
  152.         else if(OnFloor[playerid] == 0)
  153.         {
  154.             SendClientMessage(playerid,COLOR_LIGHTRED,"You are not Dieing.");
  155.         }
  156.         return 1;
  157.     }
  158.     return 0;
  159. }
  160.  
  161. dcmd_revive(playerid,params[])
  162. {
  163.     new string[128];
  164.     new giveplayerid;
  165.     new idx,tmpit[256];
  166.     tmpit = strtok(params,idx);
  167.     giveplayerid = ReturnUser(tmpit);
  168.     if(!strlen(tmpit))
  169.     {
  170.         SendClientMessage(playerid,COLOR_LIGHTRED,"Usage: /revive [playerid]");
  171.         return true;
  172.     }
  173.     new playername[MAX_PLAYER_NAME];
  174.     GetPlayerName(playerid, playername, sizeof(playername));
  175.  
  176.     new onfloorname[MAX_PLAYER_NAME];
  177.     GetPlayerName(giveplayerid, onfloorname, sizeof(onfloorname));
  178.  
  179.     new Float:px, Float:py, Float:pz;
  180.     GetPlayerPos(giveplayerid,px,py,pz);
  181.  
  182.     if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,COLOR_RED, "That player is not connected");
  183.     else if(medicpack[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"Sorry you do not have any medic packs..(/buymedicpack)");
  184.     else if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot revive yourself!");
  185.     else if(!PlayerToPoint(3.0,playerid,px,py,pz)) return SendClientMessage(playerid, COLOR_RED, "You are not close enough!");
  186.     else if(OnFloor[giveplayerid] == 0) return SendClientMessage(playerid,COLOR_RED,"That player does not need reviveing");
  187.  
  188.  
  189.     if(PlayerToPoint(3.0,playerid,px,py,pz))
  190.     {
  191.         if(IsPlayerConnected(giveplayerid))
  192.         {
  193.             format(string, sizeof(string), "you are reviving %s", onfloorname);
  194.             SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  195.  
  196.             format(string, sizeof(string), "you are being revived by %s", playername);
  197.             SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
  198.  
  199.             revid[playerid] = giveplayerid;
  200.             SetTimerEx("beingrevived", 10000, 0, "i", playerid);
  201.             return 1;
  202.         }
  203.         SendClientMessage(playerid,COLOR_RED,"INVALID ID");
  204.         return 1;
  205.     }
  206.     SendClientMessage(playerid,COLOR_RED,"You are not close enough");
  207.     return 1;
  208. }
  209.  
  210. strtok(const string[], &index)
  211. {
  212.     new length = strlen(string);
  213.     while ((index < length) && (string[index] <= ' '))
  214.     {
  215.         index++;
  216.     }
  217.  
  218.     new offset = index;
  219.     new result[20];
  220.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  221.     {
  222.         result[index - offset] = string[index];
  223.         index++;
  224.     }
  225.     result[index - offset] = EOS;
  226.     return result;
  227. }
  228.  
  229. public beingrevived(giveplayerid,playerid)
  230. {
  231.     new giveplayer = revid[playerid];
  232.     new string[128];
  233.     new onfloorguy[MAX_PLAYER_NAME];
  234.     GetPlayerName(giveplayer, onfloorguy, sizeof(onfloorguy));
  235.  
  236.     new reviver[MAX_PLAYER_NAME];
  237.     GetPlayerName(playerid, reviver, sizeof(reviver));
  238.  
  239.     format(string, sizeof(string), "you have been revived by %s", reviver);
  240.     SendClientMessage(giveplayer, COLOR_LIGHTBLUE, string);
  241.  
  242.     format(string, sizeof(string), "you have revived %s", onfloorguy);
  243.     SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  244.  
  245.     SetPlayerHealth(giveplayer, 50);
  246.     SetTimerEx("reviveddone", 1000, 0, "i", playerid);
  247.     return 1;
  248. }
  249.  
  250. public reviveddone(giveplayerid,playerid)
  251. {
  252.     new giveplayer = revid[playerid];
  253.     TogglePlayerControllable(giveplayer,1);
  254.     FirstTime[giveplayer] = 0;
  255.     OnFloor[giveplayer] = 0;
  256.     ClearAnimations(giveplayer);
  257.     revid[playerid] = 0;
  258.     medicpack[playerid] = 0;
  259.     return 1;
  260. }
  261.  
  262. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  263. {
  264.     return 1;
  265. }
  266.  
  267. public OnPlayerExitVehicle(playerid, vehicleid)
  268. {
  269.     return 1;
  270. }
  271.  
  272. public OnPlayerStateChange(playerid, newstate, oldstate)
  273. {
  274.     return 1;
  275. }
  276.  
  277. public OnPlayerEnterCheckpoint(playerid)
  278. {
  279.     return 1;
  280. }
  281.  
  282. public OnPlayerLeaveCheckpoint(playerid)
  283. {
  284.     return 1;
  285. }
  286.  
  287. public OnPlayerEnterRaceCheckpoint(playerid)
  288. {
  289.     return 1;
  290. }
  291.  
  292. public OnPlayerLeaveRaceCheckpoint(playerid)
  293. {
  294.     return 1;
  295. }
  296.  
  297. public OnRconCommand(cmd[])
  298. {
  299.     return 1;
  300. }
  301.  
  302. public OnObjectMoved(objectid)
  303. {
  304.     return 1;
  305. }
  306.  
  307. public OnPlayerObjectMoved(playerid, objectid)
  308. {
  309.     return 1;
  310. }
  311.  
  312. public OnPlayerPickUpPickup(playerid, pickupid)
  313. {
  314.     return 1;
  315. }
  316.  
  317. public OnPlayerSelectedMenuRow(playerid, row)
  318. {
  319.     return 1;
  320. }
  321.  
  322. public OnPlayerExitedMenu(playerid)
  323. {
  324.     return 1;
  325. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement