Advertisement
Guest User

Untitled

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