Guest User

Untitled

a guest
Nov 24th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.00 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3. #include <dini>
  4.  
  5. #define DIALOG_LOGIN 1
  6. #define DIALOG_REGISTER 2
  7.  
  8. static Zombie_Skin=-2;
  9.  
  10.  
  11. #define ZOMBIE_NAME "Zombie"
  12.  
  13. main()
  14. {
  15. print("\n----------------------------------");
  16. print("Zombie Script");
  17. print("----------------------------------\n");
  18. }
  19.  
  20. Itter_Create(Vehicle, MAX_VEHICLES);
  21.  
  22.  
  23. #define COLOR_GREY 0xAFAFAFAA
  24. #define COLOR_GREEN 0x33AA33AA
  25. #define COLOR_RED 0xAA3333AA
  26. #define COLOR_YELLOW 0xFFFF00AA
  27. #define COLOR_WHITE 0xFFFFFFAA
  28.  
  29. forward Spielerspawn(playerid);
  30. forward CheckCloserPlayers(playerid);
  31. forward NewPos(playerid);
  32. forward CheckHP(playerid);
  33. forward KilledBy(playerid,killer);
  34. forward KickZombie(playerid);
  35. forward Firing(playerid);
  36. forward Float:GetDistanceToPlayer(playerid,playerid2);
  37. forward Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);
  38. forward Float:GetPlayerSpeed(playerid);
  39. forward Float:GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance);
  40.  
  41. enum PlayerDaten
  42. {
  43. Level,
  44. Geld,
  45. Admin
  46. }
  47. new Spieler[MAX_PLAYERS][PlayerDaten];
  48.  
  49. new ZombieSkins[]={
  50. 1,
  51. 7,
  52. 9,
  53. 10,
  54. 45
  55. };
  56.  
  57.  
  58. enum ZombieEnum{
  59. ZombieSpawned,
  60. ZombieTarget,
  61. ZombieRunning,
  62. ZombieKilling,
  63. NPTIMER,
  64. Ztimers,
  65. Float:LastZombieHealth,
  66. Dying,
  67. HPtimer
  68. }
  69. new Zombies[200][ZombieEnum];
  70.  
  71. new FiringTimer[200];
  72. new FiringClick[200];
  73.  
  74. new ZombieKill[200];
  75.  
  76. new Caller;
  77. new LastAdded = 0;
  78.  
  79. new WeaponDamage[] = {
  80. 1,
  81. 2,
  82. 4,
  83. 4,
  84. 5,
  85. 4,
  86. 4,
  87. 4,
  88. 6,
  89. 15,
  90. -5,
  91. -5,
  92. -5,
  93. -5,
  94. -100,
  95. 4,
  96. 13,
  97. 2,
  98. 13,
  99. 0,
  100. 0,
  101. 0,
  102. 8,
  103. 9,
  104. 11,
  105. 15,
  106. 17,
  107. 15,
  108. 8,
  109. 9,
  110. 13,
  111. 13,
  112. 6,
  113. 45,
  114. 55,
  115. 40,
  116. 40,
  117. 27,
  118. 35,
  119. 0,
  120. 0,
  121. 0,
  122. 0,
  123. 0,
  124. 0,
  125. 0
  126. };
  127. new Float:WeaponRanges[] = {
  128. 1.0,
  129. 1.0,
  130. 1.2,
  131. 1.2,
  132. 1.1,
  133. 1.2,
  134. 1.2,
  135. 1.3,
  136. 1.2,
  137. 1.3,
  138. 0.5,
  139. 0.5,
  140. 0.5,
  141. 0.5,
  142. 0.5,
  143. 1.4,
  144. 12.0,
  145. 12.0,
  146. 12.0,
  147. 0.0,
  148. 0.0,
  149. 0.0,
  150. 28.0,
  151. 29.0,
  152. 30.0,
  153. 26.0,
  154. 25.0,
  155. 27.0,
  156. 28.0,
  157. 31.0,
  158. 35.0,
  159. 35.0,
  160. 26.0,
  161. 38.0,
  162. 65.0,
  163. 40.0,
  164. 40.0,
  165. 23.0,
  166. 37.0,
  167. 0.0,
  168. 0.0,
  169. 0.0,
  170. 0.0,
  171. 0.0,
  172. 0.0,
  173. 0.0
  174. };
  175. public OnGameModeInit()
  176. {
  177. DisableInteriorEnterExits();
  178. for(new i =0; i<= MAX_PLAYERS;i++){
  179. if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
  180. Itter_Add(Player,i);
  181. FiringTimer[i] = SetTimerEx("Firing",250,1,"i",i);
  182. ZombieKill[i] = -1;
  183. }
  184. else if(IsPlayerConnected(i) && IsPlayerNPC(i)){
  185. Itter_Add(Bot,i);
  186. if(!strfind(PlayerName(i),ZOMBIE_NAME,true)){
  187. SetupZombie(i);
  188. }
  189. }
  190. }
  191. new Float:h;
  192. for(new v=0;v<MAX_VEHICLES;v++){
  193. GetVehicleHealth(v,h);
  194. if(h)Itter_Add(Vehicle,v);
  195. }
  196. return 1;
  197. }
  198.  
  199. //=======================================[ Timers ]=========================================//
  200. public Firing(playerid){
  201. new up_dw,lf_rg,o_keys,weapon;
  202. new Float:x,Float:y,Float:z;
  203.  
  204. weapon = GetPlayerWeapon(playerid);
  205. GetPlayerKeys(playerid,o_keys,up_dw,lf_rg);
  206. if(o_keys == KEY_FIRE || o_keys == (KEY_FIRE+128) ){
  207. if(!FiringClick[playerid] || Automatic(weapon))
  208. {
  209. FiringClick[playerid] = true;
  210. GetPlayerPos(playerid,x,y,z);
  211. foreach(Bot,b){
  212. if(IsPlayerFacingPlayer(playerid,b,5.0)){
  213. if(IsPlayerInRangeOfPoint(b,WeaponRanges[weapon],x,y,z)){
  214. Zombies[b][LastZombieHealth] -= float(WeaponDamage[weapon]);
  215. if(Zombies[b][LastZombieHealth] <= 0.0 && !Zombies[b][Dying]){
  216. SendDeathMessage(playerid,b,weapon);
  217. Zombies[b][Dying] = true;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }else{
  224. FiringClick[playerid] = false;
  225. }
  226. }
  227. public KickZombie(playerid){
  228. Kick(playerid);
  229. Zombies[playerid][Dying]=false;
  230. KillTimer(Zombies[playerid][HPtimer]); Zombies[playerid][HPtimer] = false;
  231. KillTimer(Zombies[playerid][Ztimers]); Zombies[playerid][Ztimers] = false;
  232. if(Zombies[playerid][NPTIMER]){
  233. KillTimer(Zombies[playerid][NPTIMER]);
  234. Zombies[playerid][NPTIMER] = false;
  235. }
  236. }
  237. public CheckHP(playerid){
  238. new Float:x,Float:y,Float:z;
  239. new cp = GetClosestPlayer(playerid);
  240.  
  241. if(IsPlayerInAnyVehicle(cp)){
  242. new cpc = GetPlayerVehicleID(cp);
  243. GetVehiclePos(cpc,x,y,z);
  244. GetXYInFrontOfVehicle(cpc,x,y,1.5);
  245. if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z) && GetPlayerSpeed(cp) > 10.0){
  246. Zombies[playerid][LastZombieHealth] -= (GetPlayerSpeed(cp)*2);
  247. }
  248. }
  249. if( Zombies[playerid][LastZombieHealth] <= 0.0 && Zombies[playerid][ZombieSpawned]){
  250. ApplyAnimation(playerid,"Knife","KILL_Knife_Ped_Die",1,0,1,0,0,0);
  251. SetTimerEx("KickZombie",1500,0,"i",playerid);
  252. Zombies[playerid][Dying] = true;
  253. }
  254. }
  255.  
  256. public NewPos(playerid){
  257. if( Zombies[playerid][LastZombieHealth] > 0.0 ){
  258. new Float:x,Float:y,Float:z;
  259. new Float:ax,Float:ay,Float:az,Float:dif;
  260. GetPlayerPos(Zombies[playerid][ZombieTarget],ax,ay,az);
  261. GetPlayerPos(playerid,x,y,z);
  262. if( az <= (z+3.0) && az >= (z-3.0)){
  263. if(Zombies[playerid][ZombieRunning] == 1){
  264. ApplyAnimation(playerid,"Muscular","MuscleRun",1,1,1,0,0,0);
  265. GetXYInFrontOfPlayer(playerid,x,y,2.0);
  266. }
  267. else if(Zombies[playerid][ZombieRunning] == 2){
  268. ApplyAnimation(playerid,"Muscular","MuscleSprint",1,1,1,0,0,0);
  269. GetXYInFrontOfPlayer(playerid,x,y,2.8);
  270. }
  271.  
  272. dif = az;
  273. SetPlayerPos(playerid,x,y,dif);
  274. }else{
  275. if(Zombies[playerid][ZombieRunning]) Parar(playerid);
  276. GetPlayerPos(playerid,x,y,z);
  277. SetPlayerPosFindZ(playerid,x,y,z);
  278. }
  279. }
  280. }
  281. public CheckCloserPlayers(playerid){
  282. if( Zombies[playerid][LastZombieHealth] > 0.0 ){
  283. new cp = GetClosestPlayer(playerid);
  284. new Float:MinDistance = 3.0;
  285. if(IsPlayerInAnyVehicle(cp)){ MinDistance = 5.0; }
  286. Zombies[playerid][ZombieTarget] = cp;
  287. if(GetDistanceToPlayer(playerid,cp) <= 70.0 && GetDistanceToPlayer(playerid,cp) > 15.0){
  288. IrParaPlayer(1,playerid,cp);
  289. }else if(GetDistanceToPlayer(playerid,cp) <= 15.0 && GetDistanceToPlayer(playerid,cp) > MinDistance){
  290. IrParaPlayer(0,playerid,cp);
  291. }else if(GetDistanceToPlayer(playerid,cp) <= MinDistance){
  292. Parar(playerid);
  293. }
  294. if(GetDistanceToPlayer(playerid,cp) <= MinDistance){
  295. new Float:h;
  296. if(IsPlayerInAnyVehicle(cp)){
  297. new cpc = GetPlayerVehicleID(cp);
  298. GetVehicleHealth(cpc,h);
  299. if(GetDistanceToPlayer(playerid,cp) < MinDistance){
  300. SetVehicleHealth(cpc,h-80.0);
  301. ApplyAnimation(playerid,"Gangs","shake_carSH",1,1,1,0,0,0);
  302. }
  303.  
  304. }else{
  305. if(GetDistanceToPlayer(playerid,cp) > 1.5){
  306. GetPlayerHealth(cp,h);
  307. SetPlayerHealth(cp,h-5.0);
  308. }else if(GetDistanceToPlayer(playerid,cp) <= 1.5){
  309. if(Zombies[playerid][ZombieKilling] == -1){
  310. if(!IsDying(cp)){
  311. FinishHim(playerid,cp);
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. public KilledBy(playerid,killer){
  320. if(Zombies[killer][ZombieKilling] == playerid){
  321. ApplyAnimation(playerid,"Knife","KILL_Knife_Ped_Die",1,0,1,0,0,0);
  322. TogglePlayerControllable(playerid,true);
  323. SetPlayerHealth(playerid,0.0);
  324. ClearAnimations(killer);
  325. ZombieKill[playerid] = killer;
  326. }
  327. }
  328. //=======================================[ Functions ]=========================================//
  329. stock Automatic(weaponid){
  330. switch(weaponid){
  331. case 9,22,23,24,27,28,29,30,31,32,37,38: return true;
  332. }
  333. return false;
  334. }
  335. stock IsDying(playerid){
  336. foreach(Bot,b){
  337. if(Zombies[b][ZombieKilling] == playerid) return true;
  338. }
  339. return false;
  340. }
  341. stock SetupZombie(playerid){
  342. new Float:px,Float:py,Float:pz;
  343. Zombies[playerid][HPtimer] = SetTimerEx("CheckHP",100,1,"i",playerid);
  344. Zombies[playerid][Ztimers] = SetTimerEx("CheckCloserPlayers",1000,1,"i",playerid);
  345. GetPlayerPos(Caller,px,py,pz);
  346. SetPlayerPos(playerid,px,py,pz);
  347. Zombies[playerid][ZombieRunning] = false;
  348. SendClientMessageToAll(COLOR_RED,"A Zombie Connected!");
  349.  
  350. new Zskin=1;
  351. if(Zombie_Skin == -1){
  352. new rd = random(sizeof(ZombieSkins));
  353. if(IsValidSkin(ZombieSkins[rd])){
  354. Zskin = ZombieSkins[rd];
  355. }
  356. }else if(Zombie_Skin == -2){
  357. new rd = random(299);
  358. if(IsValidSkin(rd)){
  359. Zskin = rd;
  360. }
  361. }else if(IsValidSkin(Zombie_Skin)){
  362. Zskin = Zombie_Skin;
  363. }
  364. SetPlayerSkin(playerid,Zskin);
  365.  
  366. Zombies[playerid][ZombieKilling] = -1;
  367. Zombies[playerid][ZombieSpawned] = true;
  368. Zombies[playerid][LastZombieHealth] = 100.0;
  369. }
  370.  
  371. stock FinishHim(playerid,target){
  372. Zombies[playerid][ZombieKilling] = target;
  373. TogglePlayerControllable(target,false);
  374. SetPlayerToFacePlayer(playerid,target);
  375. SetPlayerToFacePlayer(target,playerid);
  376.  
  377. ApplyAnimation(target,"Knife","KILL_Knife_Ped_Damage",1,0,1,0,0,0);
  378. ApplyAnimation(playerid,"Knife","KILL_Knife_Player",1,0,1,0,0,0);
  379. SetTimerEx("KilledBy",1500,0,"ii",target,playerid);
  380. }
  381.  
  382. stock Parar(playerid){
  383. if(Zombies[playerid][ZombieRunning]){
  384. if(Zombies[playerid][NPTIMER]){
  385. KillTimer(Zombies[playerid][NPTIMER]);
  386. Zombies[playerid][NPTIMER] = false;
  387. }
  388. Zombies[playerid][ZombieRunning] = false;
  389. ClearAnimations(playerid);
  390. }
  391. }
  392.  
  393. stock IrParaPlayer(modo,playerid,paraid){
  394. SetPlayerToFacePlayer(playerid,paraid);
  395. if(modo == 0 && Zombies[playerid][ZombieRunning] != 1) Caminhar(playerid);
  396. else if(modo == 1 && Zombies[playerid][ZombieRunning] != 2) Correr(playerid);
  397. }
  398.  
  399. stock Caminhar(playerid){
  400. Zombies[playerid][ZombieRunning] = 1;
  401. Zombies[playerid][NPTIMER] = SetTimerEx("NewPos",400,1,"i",playerid);
  402. }
  403.  
  404. stock Correr(playerid){
  405. Zombies[playerid][ZombieRunning] = 2;
  406. Zombies[playerid][NPTIMER] = SetTimerEx("NewPos",300,1,"i",playerid);
  407. }
  408.  
  409. stock AlvoDeAlguem(alvoid){
  410. foreach(Bot,b){
  411. if(Zombies[b][ZombieTarget] == alvoid) return b;
  412. }
  413. return false;
  414. }
  415.  
  416. stock KickZombies(){
  417. foreach(Bot,b){
  418. if(!strfind(PlayerName(b),ZOMBIE_NAME,true)){
  419. SetTimerEx("KickZombie",1,0,"i",b);
  420. }
  421. }
  422. }
  423. stock SetPlayerToFacePlayer(playerid, targetid)
  424. {
  425.  
  426. new
  427. Float:pX,
  428. Float:pY,
  429. Float:pZ,
  430. Float:X,
  431. Float:Y,
  432. Float:Z,
  433. Float:ang;
  434.  
  435. if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid)) return 0;
  436.  
  437. GetPlayerPos(targetid, X, Y, Z);
  438. GetPlayerPos(playerid, pX, pY, pZ);
  439.  
  440. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  441. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  442. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  443.  
  444. if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
  445. else ang = (floatabs(ang) - 180.0);
  446.  
  447. SetPlayerFacingAngle(playerid, ang);
  448.  
  449. return 0;
  450.  
  451. }
  452.  
  453. stock PlayerName(playerid){
  454. new pname[MAX_PLAYER_NAME];
  455. GetPlayerName(playerid,pname,MAX_PLAYER_NAME);
  456. return pname;
  457. }
  458.  
  459. stock Float:GetDistanceToPlayer(playerid,playerid2) {
  460. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  461. if (!IsPlayerConnected(playerid) || !IsPlayerConnected(playerid2)) {
  462. return -1.00;
  463. }
  464. GetPlayerPos(playerid,x1,y1,z1);
  465. GetPlayerPos(playerid2,x2,y2,z2);
  466. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  467. }
  468.  
  469. stock GetClosestPlayer(p1){
  470. new Float:dis,Float:dis2,playerid;
  471. playerid = -1;
  472. dis = 99999.99;
  473. foreach(Player,x){
  474. dis2 = GetDistanceToPlayer(p1,x);
  475. if (dis2 < dis && dis2 != -1.00)
  476. {
  477. dis = dis2;
  478. playerid = x;
  479. }
  480. }
  481. //printf("[%d]%s",playerid,PlayerName(playerid));
  482. return playerid;
  483. }
  484. stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  485. {
  486. new Float:a;
  487. GetPlayerPos(playerid, x, y, a);
  488. if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  489. else GetPlayerFacingAngle(playerid, a);
  490. x += (distance * floatsin(-a, degrees));
  491. y += (distance * floatcos(-a, degrees));
  492. return a;
  493. }
  494.  
  495. stock IsValidSkin(skinid)
  496. {
  497. #define MAX_BAD_SKINS 22
  498. new badSkins[MAX_BAD_SKINS] =
  499. { 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289 };
  500. if (skinid < 0 || skinid > 299) return false;
  501. for (new i = 0; i < MAX_BAD_SKINS; i++) { if (skinid == badSkins[i]) return false; }
  502. #undef MAX_BAD_SKINS
  503. return 1;
  504. }
  505.  
  506. stock Float:GetPlayerSpeed(playerid)
  507. {
  508. new Float:vX, Float:vY, Float:vZ;
  509. if (!IsPlayerInAnyVehicle(playerid))
  510. {
  511. GetPlayerVelocity(playerid, vX, vY, vZ);
  512. }
  513. else
  514. {
  515. GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
  516. }
  517. return floatsqroot(vX*vX + vY*vY + vZ*vZ)*100;
  518. }
  519. stock Float:GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
  520. {
  521. new Float:a;
  522. GetVehiclePos(vehicleid, x, y, a);
  523. GetVehicleZAngle(vehicleid, a);
  524. x += (distance * floatsin(-a, degrees));
  525. y += (distance * floatcos(-a, degrees));
  526. return a;
  527. }
  528. stock IsPlayerFacingPlayer(playerid, playerid2, Float:dOffset)
  529. {
  530.  
  531. new
  532. Float:X,
  533. Float:Y,
  534. Float:Z,
  535. Float:pX,
  536. Float:pY,
  537. Float:pZ,
  538. Float:pA,
  539. Float:ang;
  540.  
  541. if(!IsPlayerConnected(playerid)) return 0;
  542.  
  543. GetPlayerPos(playerid2, pX, pY, pZ);
  544. GetPlayerPos(playerid, X, Y, Z);
  545. GetPlayerFacingAngle(playerid, pA);
  546.  
  547. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  548. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  549. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  550.  
  551. if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true;
  552.  
  553. return false;
  554. }
  555.  
  556. stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
  557. {
  558.  
  559. a1 -= a2;
  560. if((a1 < range) && (a1 > -range)) return true;
  561.  
  562. return false;
  563.  
  564. }
  565. //=======================================[ Callbacks ]=========================================//
  566.  
  567. public OnGameModeExit()
  568. {
  569. KickZombies();
  570. return 1;
  571. }
  572. public OnPlayerRequestClass(playerid, classid)
  573. {
  574. SetPlayerPos(playerid, -1970.9844,106.7734,27.6875);
  575. SetPlayerFacingAngle(playerid,176.1210);
  576. SetPlayerCameraPos(playerid, -1971.4865,95.3334+10,27.6875);
  577. SetPlayerCameraLookAt(playerid, -1971.4865,95.3334,27.6875);
  578. SetTimerEx("Spielerspawn",50,0,"i",playerid);
  579. return 1;
  580. }
  581.  
  582. public OnPlayerConnect(playerid)
  583. {
  584. if(IsPlayerNPC(playerid)){ SpawnPlayer(playerid); }
  585. else{
  586. FiringTimer[playerid] = SetTimerEx("Firing",250,1,"i",playerid);
  587. }
  588. new Playerdatei[128];
  589. new name[MAX_PLAYER_NAME];
  590. GetPlayerName(playerid,name,sizeof(name));
  591. format(Playerdatei,sizeof(Playerdatei),"/Accounts/%s.ini",name);
  592. if(dini_Exists(Playerdatei)){
  593. ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Login","Bitte geben sie ihr richtiges Passwort ein.","Einloggen","Abbrechen");
  594. }
  595. else{
  596. ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Registration","Bitte Registrieren sie sich mit ihrem gewünschtem Passwort","Registerieren","Abbrechen");
  597. }
  598. return 1;
  599. }
  600.  
  601. public OnPlayerDisconnect(playerid, reason)
  602. {
  603. if(!IsPlayerNPC(playerid)){
  604. KillTimer(FiringTimer[playerid]);
  605. }
  606. new Float:x, Float:y, Float:z;
  607. GetPlayerPos(playerid, x, y, z);
  608. if(GetPVarInt(playerid,"Eingeloggt") == 1){
  609. SpielerSpeichern(playerid);
  610. }
  611.  
  612. return 1;
  613. }
  614.  
  615. public OnPlayerSpawn(playerid)
  616. {
  617. if(IsPlayerNPC(playerid)){
  618. if(!strfind(PlayerName(playerid),ZOMBIE_NAME,true)){
  619. SetupZombie(playerid);
  620. }
  621. }
  622. if(ZombieKill[playerid] != -1){
  623. Zombies[ZombieKill[playerid]][ZombieKilling] = -1;
  624. ZombieKill[playerid] = -1;
  625. return 1;
  626. }
  627. return 1;
  628. }
  629.  
  630. public OnPlayerDeath(playerid, killerid, reason)
  631. {
  632. if(ZombieKill[playerid] != -1){
  633. SendDeathMessage(ZombieKill[playerid],playerid,reason);
  634. return 1;
  635. }
  636. return 1;
  637. }
  638.  
  639. public OnVehicleSpawn(vehicleid)
  640. {
  641. return 1;
  642. }
  643.  
  644. public OnVehicleDeath(vehicleid, killerid)
  645. {
  646. return 1;
  647. }
  648.  
  649. public OnPlayerText(playerid, text[])
  650. {
  651. return 1;
  652. }
  653.  
  654. public OnPlayerCommandText(playerid, cmdtext[])
  655. {
  656. if(strcmp(cmdtext, "/zombie", true) == 0) {
  657. if(!IsPlayerAdmin(playerid)) return false;
  658. Caller = playerid;
  659. new newname[64];
  660. format(newname,sizeof(newname),"%s_%d",ZOMBIE_NAME,LastAdded);
  661. ConnectNPC(newname,"zombie");
  662. LastAdded++;
  663. return 1;
  664. }
  665. return 0;
  666. }
  667.  
  668. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  669. {
  670. return 1;
  671. }
  672.  
  673. public OnPlayerExitVehicle(playerid, vehicleid)
  674. {
  675. return 1;
  676. }
  677.  
  678. public OnPlayerStateChange(playerid, newstate, oldstate)
  679. {
  680. return 1;
  681. }
  682.  
  683. public OnPlayerEnterCheckpoint(playerid)
  684. {
  685. return 1;
  686. }
  687.  
  688. public OnPlayerLeaveCheckpoint(playerid)
  689. {
  690. return 1;
  691. }
  692.  
  693. public OnPlayerEnterRaceCheckpoint(playerid)
  694. {
  695. return 1;
  696. }
  697.  
  698. public OnPlayerLeaveRaceCheckpoint(playerid)
  699. {
  700. return 1;
  701. }
  702.  
  703. public OnRconCommand(cmd[])
  704. {
  705. return 1;
  706. }
  707.  
  708. public OnPlayerRequestSpawn(playerid)
  709. {
  710. return 1;
  711. }
  712.  
  713. public OnObjectMoved(objectid)
  714. {
  715. return 1;
  716. }
  717.  
  718. public OnPlayerObjectMoved(playerid, objectid)
  719. {
  720. return 1;
  721. }
  722.  
  723. public OnPlayerPickUpPickup(playerid, pickupid)
  724. {
  725. return 1;
  726. }
  727.  
  728. public OnVehicleMod(playerid, vehicleid, componentid)
  729. {
  730. return 1;
  731. }
  732.  
  733. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  734. {
  735. return 1;
  736. }
  737.  
  738. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  739. {
  740. return 1;
  741. }
  742.  
  743. public OnPlayerSelectedMenuRow(playerid, row)
  744. {
  745. return 1;
  746. }
  747.  
  748. public OnPlayerExitedMenu(playerid)
  749. {
  750. return 1;
  751. }
  752.  
  753. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  754. {
  755. return 1;
  756. }
  757.  
  758. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  759. {
  760. return 1;
  761. }
  762.  
  763. public OnRconLoginAttempt(ip[], password[], success)
  764. {
  765. return 1;
  766. }
  767.  
  768. public OnPlayerUpdate(playerid)
  769. {
  770. return 1;
  771. }
  772.  
  773. public OnPlayerStreamIn(playerid, forplayerid)
  774. {
  775. return 1;
  776. }
  777.  
  778. public OnPlayerStreamOut(playerid, forplayerid)
  779. {
  780. return 1;
  781. }
  782.  
  783. public OnVehicleStreamIn(vehicleid, forplayerid)
  784. {
  785. return 1;
  786. }
  787.  
  788. public OnVehicleStreamOut(vehicleid, forplayerid)
  789. {
  790. return 1;
  791. }
  792.  
  793. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  794. {
  795. if(dialogid == DIALOG_LOGIN){
  796. if(response == 0){
  797. SendClientMessage(playerid,COLOR_RED,"Sie haben den Login Vorgang abgebrochen. Sie werden nun gekickt!");
  798. Kick(playerid);
  799. return 1;
  800. }
  801. if(response == 1){
  802. if(!strlen(inputtext)){
  803. SendClientMessage(playerid,COLOR_GREEN,"Bitte geben sie ein längeres Passwort ein!");
  804. ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Login","Ihr Account wurde in unserer Datenbank gefunden!\nBitte gebe nun dein Passwort ein! ","Einloggen", "Abbrechen");
  805. return 1;
  806. }
  807. else{
  808. Login(playerid,inputtext);
  809. new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  810. GetPlayerName(playerid, pname, sizeof(pname));
  811. format(string, sizeof(string), "%s hat sich Eingeloggt.", pname);
  812. printf(string);
  813. return 1;
  814. }
  815. }
  816.  
  817. }
  818. if(dialogid == DIALOG_REGISTER){
  819. if(response == 0){
  820. SendClientMessage(playerid,COLOR_RED,"Sie haben die Registration erfolgreich Abgebrochen. Sie werden nun gekickt!");
  821. Kick(playerid);
  822. return 1;
  823. }
  824. if(response == 1){
  825. if(!strlen(inputtext)){
  826. SendClientMessage(playerid,COLOR_GREEN,"Ihr angegebenes Passwort war nicht lang genug!");
  827. ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Registrierung auf My Own Life","Willkommen auf My Own Life!\nBitte geben sie nun ihr gewünschtes Passwort ein.","Registrieren","Abbrechen");
  828. return 1;
  829. }
  830. else{
  831. Register(playerid,inputtext);
  832. GivePlayerMoney(playerid,6000);
  833. return 1;
  834. }
  835. }
  836. }
  837. return 1;
  838. }
  839. stock Register(playerid,key[]){
  840. new Playerdatei[128];
  841. new name[MAX_PLAYER_NAME];
  842. GetPlayerName(playerid,name,sizeof(name));
  843. format(Playerdatei,sizeof(Playerdatei),"/Accounts/%s.ini",name);
  844. dini_Create(Playerdatei);
  845. dini_Set(Playerdatei,"Passwort",key);
  846. SetPlayerScore(playerid,0);
  847. dini_IntSet(Playerdatei,"Admin",0);
  848. SetPVarInt(playerid,"Eingeloggt",1);
  849. SetPVarFloat(playerid,"lastxpos",-1961.6096);
  850. SetPVarFloat(playerid,"lastypos",294.5707);
  851. SetPVarFloat(playerid,"lastzpos",35.4688);
  852. SpielerSpeichern(playerid);
  853. return 1;
  854. }
  855. stock Login(playerid,key[]){
  856. new Playerdatei[128];
  857. new name[MAX_PLAYER_NAME];
  858. GetPlayerName(playerid,name,sizeof(name));
  859. format(Playerdatei,sizeof(Playerdatei),"/Accounts/%s.ini",name);
  860. if(!strcmp(key,dini_Get(Playerdatei,"Passwort"),false)){
  861. AccountLaden(playerid);
  862. }
  863. else{
  864. SendClientMessage(playerid,COLOR_GREEN,"Du hast ein falsches Passwort eingegeben!");
  865. ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Login","Dein Account wurde in unserer Datenbank gefunden!\nBitte gib nun dein Passwort ein! ","Login", "Abbrechen");
  866. }
  867. return 1;
  868. }
  869. stock SpielerName(playerid)
  870. {
  871. new name[MAX_PLAYERS];
  872. GetPlayerName(playerid,name,sizeof(name));
  873. return name;
  874. }
  875. stock AccountLaden(playerid){
  876. new Playerdatei[128];
  877. new name[MAX_PLAYER_NAME];
  878. GetPlayerName(playerid,name,sizeof(name));
  879. format(Playerdatei,sizeof(Playerdatei),"/Accounts/%s.ini",name);
  880. Spieler[playerid][Level] = dini_Int(Playerdatei,"Level");
  881. Spieler[playerid][Admin] = dini_Int(Playerdatei,"Admin");
  882. GivePlayerMoney(playerid, dini_Int(Playerdatei, "Geld"));
  883. SetPVarFloat(playerid,"lastxpos",dini_Float(Playerdatei,"lastxpos"));
  884. SetPVarFloat(playerid,"lastypos",dini_Float(Playerdatei,"lastypos"));
  885. SetPVarFloat(playerid,"lastzpos",dini_Float(Playerdatei,"lastzpos"));
  886. SetPVarInt(playerid,"Eingeloggt",1);
  887. return 1;
  888. }
  889. stock SpielerSpeichern(playerid)
  890. {
  891. if(GetPVarInt(playerid,"Eingeloggt") == 1)
  892. {
  893. new Playerdatei[128];
  894. new name[MAX_PLAYER_NAME];
  895. GetPlayerName(playerid,name,sizeof(name));
  896. format(Playerdatei,sizeof(Playerdatei),"/Accounts/%s.ini",name);
  897. dini_IntSet(Playerdatei,"Level", Spieler[playerid][Level]);
  898. dini_IntSet(Playerdatei, "Admin", Spieler[playerid][Admin]);
  899. dini_IntSet(Playerdatei, "Geld", GetPlayerMoney(playerid));
  900. dini_FloatSet(Playerdatei,"lastxpos",GetPVarFloat(playerid,"lastxpos"));
  901. dini_FloatSet(Playerdatei,"lastypos",GetPVarFloat(playerid,"lastypos"));
  902. dini_FloatSet(Playerdatei,"lastzpos",GetPVarFloat(playerid,"lastzpos"));
  903. }
  904.  
  905. }
  906.  
  907. stock IstSpielerAdmin(playerid, alevel)
  908. {
  909. if(Spieler[playerid][Admin] >= alevel) return 1;
  910. return 0;
  911. }
  912.  
  913.  
  914. public Spielerspawn(playerid)
  915. {
  916. SpawnPlayer(playerid);
  917. return 1;
  918. }
Advertisement
Add Comment
Please, Sign In to add comment