Guest User

Untitled

a guest
Nov 25th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.05 KB | None | 0 0
  1. public Firing(playerid){
  2. new up_dw,lf_rg,o_keys,weapon;
  3. new Float:x,Float:y,Float:z;
  4.  
  5. weapon = GetPlayerWeapon(playerid);
  6. GetPlayerKeys(playerid,o_keys,up_dw,lf_rg);
  7. if(o_keys == KEY_FIRE || o_keys == (KEY_FIRE+128) ){
  8. if(!FiringClick[playerid] || Automatic(weapon))
  9. {
  10. FiringClick[playerid] = true;
  11. GetPlayerPos(playerid,x,y,z);
  12. foreach(Bot,b){
  13. if(IsPlayerFacingPlayer(playerid,b,5.0)){
  14. if(IsPlayerInRangeOfPoint(b,WeaponRanges[weapon],x,y,z)){
  15. Zombies[b][LastZombieHealth] -= float(WeaponDamage[weapon]);
  16. if(Zombies[b][LastZombieHealth] <= 0.0 && !Zombies[b][Dying]){
  17. SendDeathMessage(playerid,b,weapon);
  18. Zombies[b][Dying] = true;
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }else{
  25. FiringClick[playerid] = false;
  26. }
  27. }
  28. public KickZombie(playerid){
  29. Kick(playerid);
  30. Zombies[playerid][Dying]=false;
  31. KillTimer(Zombies[playerid][HPtimer]); Zombies[playerid][HPtimer] = false;
  32. KillTimer(Zombies[playerid][Ztimers]); Zombies[playerid][Ztimers] = false;
  33. if(Zombies[playerid][NPTIMER]){
  34. KillTimer(Zombies[playerid][NPTIMER]);
  35. Zombies[playerid][NPTIMER] = false;
  36. }
  37. }
  38. public CheckHP(playerid){
  39. new Float:x,Float:y,Float:z;
  40. new cp = GetClosestPlayer(playerid);
  41.  
  42. if(IsPlayerInAnyVehicle(cp)){
  43. new cpc = GetPlayerVehicleID(cp);
  44. GetVehiclePos(cpc,x,y,z);
  45. GetXYInFrontOfVehicle(cpc,x,y,1.5);
  46. if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z) && GetPlayerSpeed(cp) > 10.0){
  47. Zombies[playerid][LastZombieHealth] -= (GetPlayerSpeed(cp)*2);
  48. }
  49. }
  50. if( Zombies[playerid][LastZombieHealth] <= 0.0 && Zombies[playerid][ZombieSpawned]){
  51. // ApplyAnimation(playerid,"Knife","KILL_Knife_Ped_Die",1,0,1,0,0,0);
  52. SetTimerEx("KickZombie",1500,0,"i",playerid);
  53. Zombies[playerid][Dying] = true;
  54. }
  55. }
  56.  
  57. public NewPos(playerid){
  58. if( Zombies[playerid][LastZombieHealth] > 0.0 ){
  59. new Float:x,Float:y,Float:z;
  60. new Float:ax,Float:ay,Float:az,Float:dif;
  61. GetPlayerPos(Zombies[playerid][ZombieTarget],ax,ay,az);
  62. GetPlayerPos(playerid,x,y,z);
  63. if( az <= (z+3.0) && az >= (z-3.0)){
  64. if(Zombies[playerid][ZombieRunning] == 1){
  65. ApplyAnimation(playerid,"Muscular","MuscleRun",1,1,1,0,0,0);
  66. GetXYInFrontOfPlayer(playerid,x,y,2.0);
  67. }
  68. else if(Zombies[playerid][ZombieRunning] == 2){
  69. ApplyAnimation(playerid,"Muscular","MuscleSprint",1,1,1,0,0,0);
  70. GetXYInFrontOfPlayer(playerid,x,y,2.8);
  71. }
  72.  
  73. dif = az;
  74. SetPlayerPos(playerid,x,y,dif);
  75. }else{
  76. if(Zombies[playerid][ZombieRunning]) Parar(playerid);
  77. GetPlayerPos(playerid,x,y,z);
  78. SetPlayerPosFindZ(playerid,x,y,z);
  79. }
  80. }
  81. }
  82. public CheckCloserPlayers(playerid){
  83. if( Zombies[playerid][LastZombieHealth] > 0.0 ){
  84. new cp = GetClosestPlayer(playerid);
  85. new Float:MinDistance = 3.0;
  86. if(IsPlayerInAnyVehicle(cp)){ MinDistance = 5.0; }
  87. Zombies[playerid][ZombieTarget] = cp;
  88. if(GetDistanceToPlayer(playerid,cp) <= 70.0 && GetDistanceToPlayer(playerid,cp) > 15.0){
  89. IrParaPlayer(1,playerid,cp);
  90. }else if(GetDistanceToPlayer(playerid,cp) <= 15.0 && GetDistanceToPlayer(playerid,cp) > MinDistance){
  91. IrParaPlayer(0,playerid,cp);
  92. }else if(GetDistanceToPlayer(playerid,cp) <= MinDistance){
  93. Parar(playerid);
  94. }
  95. if(GetDistanceToPlayer(playerid,cp) <= MinDistance){
  96. new Float:h;
  97. if(IsPlayerInAnyVehicle(cp)){
  98. new cpc = GetPlayerVehicleID(cp);
  99. GetVehicleHealth(cpc,h);
  100. if(GetDistanceToPlayer(playerid,cp) < MinDistance){
  101. SetVehicleHealth(cpc,h-80.0);
  102. ApplyAnimation(playerid,"Gangs","shake_carSH",1,1,1,0,0,0);
  103. }
  104.  
  105. }else{
  106. if(GetDistanceToPlayer(playerid,cp) > 1.5){
  107. GetPlayerHealth(cp,h);
  108. SetPlayerHealth(cp,h-5.0);
  109. }else if(GetDistanceToPlayer(playerid,cp) <= 1.5){
  110. if(Zombies[playerid][ZombieKilling] == -1){
  111. if(!IsDying(cp)){
  112. FinishHim(playerid,cp);
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. public KilledBy(playerid,killer){
  121. if(Zombies[killer][ZombieKilling] == playerid){
  122. //ApplyAnimation(playerid,"Knife","KILL_Knife_Ped_Die",1,0,1,0,0,0);
  123. TogglePlayerControllable(playerid,true);
  124. // SetPlayerHealth(playerid,0.0);
  125. ClearAnimations(killer);
  126. print("Player wird HP Abgezogen");
  127. Var_Timer = SetTimerEx("Hp_Weg", 5000, 1, "i", playerid);
  128. ZombieKill[playerid] = killer;
  129. }
  130. }
  131. forward Hp_Weg(playerid);
  132. public Hp_Weg(playerid){
  133. TogglePlayerControllable(playerid,1);
  134. new Float:health;
  135. GetPlayerHealth(playerid, health);
  136. SetPlayerHealth(playerid, health-5);
  137. KillTimer(Var_Timer);
  138. return 1;
  139. }
  140. stock Automatic(weaponid){
  141. switch(weaponid){
  142. case 9,22,23,24,27,28,29,30,31,32,37,38: return true;
  143. }
  144. return false;
  145. }
  146. stock IsDying(playerid){
  147. foreach(Bot,b){
  148. if(Zombies[b][ZombieKilling] == playerid) return true;
  149. }
  150. return false;
  151. }
  152. stock SetupZombie(playerid){
  153. new Float:px,Float:py,Float:pz;
  154. Zombies[playerid][HPtimer] = SetTimerEx("CheckHP",100,1,"i",playerid);
  155. Zombies[playerid][Ztimers] = SetTimerEx("CheckCloserPlayers",1000,1,"i",playerid);
  156. GetPlayerPos(Caller,px,py,pz);
  157. SetPlayerPos(playerid,px,py,pz);
  158. Zombies[playerid][ZombieRunning] = false;
  159. SendClientMessageToAll(COLOR_RED,"A Zombie Connected!");
  160.  
  161. new Zskin=1;
  162. if(Zombie_Skin == -1){
  163. new rd = random(sizeof(ZombieSkins));
  164. if(IsValidSkin(ZombieSkins[rd])){
  165. Zskin = ZombieSkins[rd];
  166. }
  167. }else if(Zombie_Skin == -2){
  168. new rd = random(299);
  169. if(IsValidSkin(rd)){
  170. Zskin = rd;
  171. }
  172. }else if(IsValidSkin(Zombie_Skin)){
  173. Zskin = Zombie_Skin;
  174. }
  175. SetPlayerSkin(playerid,Zskin);
  176.  
  177. Zombies[playerid][ZombieKilling] = -1;
  178. Zombies[playerid][ZombieSpawned] = true;
  179. Zombies[playerid][LastZombieHealth] = 100.0;
  180. }
  181.  
  182. stock FinishHim(playerid,target){
  183. Zombies[playerid][ZombieKilling] = target;
  184. TogglePlayerControllable(target,false);
  185. SetPlayerToFacePlayer(playerid,target);
  186. SetPlayerToFacePlayer(target,playerid);
  187.  
  188. // ApplyAnimation(target,"Knife","KILL_Knife_Ped_Damage",1,0,1,0,0,0);
  189. // ApplyAnimation(playerid,"Knife","KILL_Knife_Player",1,0,1,0,0,0);
  190. SetTimerEx("KilledBy",1500,0,"ii",target,playerid);
  191. }
  192.  
  193. stock Parar(playerid){
  194. if(Zombies[playerid][ZombieRunning]){
  195. if(Zombies[playerid][NPTIMER]){
  196. KillTimer(Zombies[playerid][NPTIMER]);
  197. Zombies[playerid][NPTIMER] = false;
  198. }
  199. Zombies[playerid][ZombieRunning] = false;
  200. ClearAnimations(playerid);
  201. }
  202. }
  203.  
  204. stock IrParaPlayer(modo,playerid,paraid){
  205. SetPlayerToFacePlayer(playerid,paraid);
  206. if(modo == 0 && Zombies[playerid][ZombieRunning] != 1) Caminhar(playerid);
  207. else if(modo == 1 && Zombies[playerid][ZombieRunning] != 2) Correr(playerid);
  208. }
  209.  
  210. stock Caminhar(playerid){
  211. Zombies[playerid][ZombieRunning] = 1;
  212. Zombies[playerid][NPTIMER] = SetTimerEx("NewPos",400,1,"i",playerid);
  213. }
  214.  
  215. stock Correr(playerid){
  216. Zombies[playerid][ZombieRunning] = 2;
  217. Zombies[playerid][NPTIMER] = SetTimerEx("NewPos",300,1,"i",playerid);
  218. }
  219.  
  220. stock AlvoDeAlguem(alvoid){
  221. foreach(Bot,b){
  222. if(Zombies[b][ZombieTarget] == alvoid) return b;
  223. }
  224. return false;
  225. }
  226.  
  227. stock KickZombies(){
  228. foreach(Bot,b){
  229. if(!strfind(PlayerName(b),ZOMBIE_NAME,true)){
  230. SetTimerEx("KickZombie",1,0,"i",b);
  231. }
  232. }
  233. }
  234. stock SetPlayerToFacePlayer(playerid, targetid)
  235. {
  236.  
  237. new
  238. Float:pX,
  239. Float:pY,
  240. Float:pZ,
  241. Float:X,
  242. Float:Y,
  243. Float:Z,
  244. Float:ang;
  245.  
  246. if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid)) return 0;
  247.  
  248. GetPlayerPos(targetid, X, Y, Z);
  249. GetPlayerPos(playerid, pX, pY, pZ);
  250.  
  251. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  252. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  253. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  254.  
  255. if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
  256. else ang = (floatabs(ang) - 180.0);
  257.  
  258. SetPlayerFacingAngle(playerid, ang);
  259.  
  260. return 0;
  261.  
  262. }
  263.  
  264. stock PlayerName(playerid){
  265. new pname[MAX_PLAYER_NAME];
  266. GetPlayerName(playerid,pname,MAX_PLAYER_NAME);
  267. return pname;
  268. }
  269.  
  270. stock Float:GetDistanceToPlayer(playerid,playerid2) {
  271. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  272. if (!IsPlayerConnected(playerid) || !IsPlayerConnected(playerid2)) {
  273. return -1.00;
  274. }
  275. GetPlayerPos(playerid,x1,y1,z1);
  276. GetPlayerPos(playerid2,x2,y2,z2);
  277. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  278. }
  279.  
  280. stock GetClosestPlayer(p1){
  281. new Float:dis,Float:dis2,playerid;
  282. playerid = -1;
  283. dis = 99999.99;
  284. foreach(Player,x){
  285. dis2 = GetDistanceToPlayer(p1,x);
  286. if (dis2 < dis && dis2 != -1.00)
  287. {
  288. dis = dis2;
  289. playerid = x;
  290. }
  291. }
  292. //printf("[%d]%s",playerid,PlayerName(playerid));
  293. return playerid;
  294. }
  295. stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  296. {
  297. new Float:a;
  298. GetPlayerPos(playerid, x, y, a);
  299. if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  300. else GetPlayerFacingAngle(playerid, a);
  301. x += (distance * floatsin(-a, degrees));
  302. y += (distance * floatcos(-a, degrees));
  303. return a;
  304. }
  305.  
  306. stock IsValidSkin(skinid)
  307. {
  308. #define MAX_BAD_SKINS 22
  309. new badSkins[MAX_BAD_SKINS] =
  310. { 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289 };
  311. if (skinid < 0 || skinid > 299) return false;
  312. for (new i = 0; i < MAX_BAD_SKINS; i++) { if (skinid == badSkins[i]) return false; }
  313. #undef MAX_BAD_SKINS
  314. return 1;
  315. }
  316.  
  317. stock Float:GetPlayerSpeed(playerid)
  318. {
  319. new Float:vX, Float:vY, Float:vZ;
  320. if (!IsPlayerInAnyVehicle(playerid))
  321. {
  322. GetPlayerVelocity(playerid, vX, vY, vZ);
  323. }
  324. else
  325. {
  326. GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
  327. }
  328. return floatsqroot(vX*vX + vY*vY + vZ*vZ)*100;
  329. }
  330. stock Float:GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
  331. {
  332. new Float:a;
  333. GetVehiclePos(vehicleid, x, y, a);
  334. GetVehicleZAngle(vehicleid, a);
  335. x += (distance * floatsin(-a, degrees));
  336. y += (distance * floatcos(-a, degrees));
  337. return a;
  338. }
  339. stock IsPlayerFacingPlayer(playerid, playerid2, Float:dOffset)
  340. {
  341.  
  342. new
  343. Float:X,
  344. Float:Y,
  345. Float:Z,
  346. Float:pX,
  347. Float:pY,
  348. Float:pZ,
  349. Float:pA,
  350. Float:ang;
  351.  
  352. if(!IsPlayerConnected(playerid)) return 0;
  353.  
  354. GetPlayerPos(playerid2, pX, pY, pZ);
  355. GetPlayerPos(playerid, X, Y, Z);
  356. GetPlayerFacingAngle(playerid, pA);
  357.  
  358. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  359. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  360. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  361.  
  362. if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true;
  363.  
  364. return false;
  365. }
  366.  
  367. stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
  368. {
  369.  
  370. a1 -= a2;
  371. if((a1 < range) && (a1 > -range)) return true;
  372.  
  373. return false;
  374.  
  375. }
Advertisement
Add Comment
Please, Sign In to add comment