Advertisement
Guest User

GunGame - by DasNeo

a guest
Jan 17th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 21.50 KB | None | 0 0
  1. // Dieses Script wurde von DasNeo geschrieben.
  2. #include <a_samp>
  3. #include <Dini>
  4. #include <ocmd>
  5.  
  6. #define DIALOG_REGIST1 1
  7. #define DIALOG_LOGIN 2
  8. #define DIALOG_NOPW 3
  9. #define DIALOG_NOPW2 4
  10. #define DIALOG_WRONGPW 5
  11.  
  12. #define COLOR_GRAY 0xBEBEBEFF
  13. #define COLOR_RED 0xFF0000FF
  14. #define COLOR_GREEN 0x00FF00FF
  15. #define COLOR_TURKIS 0x00FFE6FF
  16. #define COLOR_WHITE 0xFFFFFFFF
  17.  
  18. new Text:fuehrender;
  19.  
  20. new Float:RandomSpawn[][3] =
  21. {
  22.     {1377.2893,2195.7578,9.7578},
  23.     {1372.7399,2195.3296,9.7578},
  24.     {1368.6169,2195.3647,9.7578},
  25.     {1364.6364,2195.8181,9.7578},
  26.     {1360.4471,2195.6870,9.7578},
  27.     {1394.9082,2177.4573,9.7578},
  28.     {1394.6724,2173.6697,9.7578},
  29.     {1394.4272,2169.1064,9.7578},
  30.     {1394.6779,2164.6282,9.7578},
  31.     {1394.4634,2160.0500,9.7578}
  32. };
  33.  
  34. main()
  35. {
  36.     print("\n----------------------------------");
  37.     print("--------GunGame by DasNeo-----------");
  38.     print("----------------------------------\n");
  39. }
  40.  
  41. public OnGameModeInit()
  42. {
  43.     SetGameModeText("GunGame");
  44.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  45.     SetTimer("hoechstesLevel", 30000, true);
  46.     fuehrender = TextDrawCreate(148.0,416.0,"");
  47.     TextDrawColor(fuehrender,0xBEBEBEFF);
  48.     return 1;
  49. }
  50.  
  51. public OnGameModeExit()
  52. {
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerRequestClass(playerid, classid)
  57. {
  58.     SpawnPlayer(playerid);
  59.     SetPlayerCameraPos(playerid,123,123,123);
  60.     SetPlayerCameraLookAt(playerid, 123.1,123.1,123.1, 1);
  61.     return 1;
  62. }
  63.  
  64. public OnPlayerConnect(playerid)
  65. {
  66.     new path[128];
  67.     format(path, sizeof(path), "/accounts/%s.ini", spielerName(playerid));
  68.     new willkommen[128];
  69.     format(willkommen,sizeof(willkommen), "{FFA000}[#] {A0A0A0}%s ist dem Spiel beigetreten.",spielerName(playerid));
  70.     SendClientMessageToAll(COLOR_GRAY, willkommen);
  71.     if(!dini_Exists(path))
  72.     {
  73.         ShowPlayerDialog(playerid, DIALOG_REGIST1, DIALOG_STYLE_PASSWORD, "Registrierung", "Wir heissen dich herzlichst\nauf unserem Server willkommen.\nBitte geben Sie hier Ihr gewuenschtes Passwort ein:", "Weiter", "Abbrechen");
  74.     }
  75.     else
  76.     {
  77.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Geben Sie Ihr Passwort ein:", "Login", "Abbrechen");
  78.     }
  79.     if(GetPVarInt(playerid, "banned") == 1)
  80.     {
  81.         SendClientMessage(playerid, COLOR_RED, "Du wurdest von diesem Server gebannt!");
  82.         Kick(playerid);
  83.     }
  84.     return 1;
  85. }
  86.  
  87. forward spielerName(playerid);
  88. stock spielerName(playerid)
  89. {
  90.     new name[128];
  91.     GetPlayerName(playerid,name,sizeof(name));
  92.     return name;
  93. }
  94.  
  95. forward spielerLaden(playerid);
  96. public spielerLaden(playerid)
  97. {
  98.     new path[128];
  99.     format(path, sizeof(path), "/accounts/%s.ini", spielerName(playerid));
  100.     SetPVarInt(playerid, "Level", dini_Int(path, "Level"));
  101.     SetPVarInt(playerid, "Gewonnen", dini_Int(path, "Level"));
  102.     SetPVarInt(playerid, "Auswahl", dini_Int(path, "Auswahl"));
  103.     SetPVarInt(playerid, "banned", dini_Int(path, "banned"));
  104.     SetPVarInt(playerid, "admin", dini_Int(path, "admin"));
  105.     return 1;
  106. }
  107.  
  108. forward spielerSpeichern(playerid);
  109. public spielerSpeichern(playerid)
  110. {
  111.     new path[128];
  112.     format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
  113.     dini_IntSet(path, "Level", GetPVarInt(playerid,"Level"));
  114.     dini_IntSet(path, "Gewonnen", GetPVarInt(playerid, "Gewonnen"));
  115.     dini_IntSet(path, "Auswahl", GetPVarInt(playerid, "Auswahl"));
  116.     dini_IntSet(path, "banned", GetPVarInt(playerid, "banned"));
  117.     dini_IntSet(path, "admin", GetPVarInt(playerid, "admin"));
  118.     return 1;
  119. }
  120.  
  121. public OnPlayerDisconnect(playerid, reason)
  122. {
  123.     SetPVarInt(playerid, "Level", 0);
  124.     spielerSpeichern(playerid);
  125.     return 1;
  126. }
  127.  
  128. public OnPlayerSpawn(playerid)
  129. {
  130.     TextDrawShowForPlayer(playerid, fuehrender);
  131.     TogglePlayerControllable(playerid, 1);
  132.     spielerLaden(playerid);
  133.     SetPlayerPos(playerid, 1377.2893,2195.7578,9.7578);
  134.     levelUp(playerid);
  135.     spielerSpeichern(playerid);
  136.     new rand = random(sizeof(RandomSpawn));
  137.     SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
  138.     return 1;
  139. }
  140.  
  141. forward RoundStart();
  142. public RoundStart()
  143. {
  144.     new path[128];
  145.     for(new i=0; i < MAX_PLAYERS; i++)
  146.     {
  147.         format(path,sizeof(path), "/accounts/%.ini", spielerName(i));
  148.         dini_IntSet(path,"Level",0);
  149.         SetPVarInt(i, "Level",0);
  150.         spielerSpeichern(i);
  151.         SpawnPlayer(i);
  152.     }  
  153.     return 1;
  154. }
  155.  
  156. forward levelUp(playerid);
  157. public levelUp(playerid)
  158. {
  159.     new path[128];
  160.     format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
  161.     switch(GetPVarInt(playerid,"Level"))
  162.     {
  163.         case 0:
  164.         {
  165.             ResetPlayerWeapons(playerid);
  166.             GivePlayerWeapon(playerid, 22, 20000);
  167.         }
  168.         case 1:
  169.         {
  170.             ResetPlayerWeapons(playerid);
  171.             GivePlayerWeapon(playerid, 23, 20000);
  172.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 1/21.");
  173.         }
  174.         case 2:
  175.         {
  176.             ResetPlayerWeapons(playerid);
  177.             GivePlayerWeapon(playerid, 24, 20000);
  178.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 2/21.");
  179.         }
  180.         case 3:
  181.         {
  182.             ResetPlayerWeapons(playerid);
  183.             GivePlayerWeapon(playerid, 25, 20000);
  184.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 3/21.");
  185.         }
  186.         case 4:
  187.         {
  188.             ResetPlayerWeapons(playerid);
  189.             GivePlayerWeapon(playerid, 27, 20000);
  190.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 4/21.");
  191.         }
  192.         case 5:
  193.         {
  194.             ResetPlayerWeapons(playerid);
  195.             GivePlayerWeapon(playerid, 26, 20000);
  196.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 5/21.");
  197.         }
  198.         case 6:
  199.         {
  200.             ResetPlayerWeapons(playerid);
  201.             GivePlayerWeapon(playerid, 28, 20000);
  202.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 6/21.");
  203.         }
  204.         case 7:
  205.         {
  206.             ResetPlayerWeapons(playerid);
  207.             GivePlayerWeapon(playerid, 29, 20000);
  208.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 7/21.");
  209.         }
  210.         case 8:
  211.         {
  212.             ResetPlayerWeapons(playerid);
  213.             GivePlayerWeapon(playerid, 32, 20000);
  214.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 8/21.");
  215.         }
  216.         case 9:
  217.         {
  218.             ResetPlayerWeapons(playerid);
  219.             GivePlayerWeapon(playerid, 30, 20000);
  220.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 9/21.");
  221.         }
  222.         case 10:
  223.         {
  224.             ResetPlayerWeapons(playerid);
  225.             GivePlayerWeapon(playerid, 31, 20000);
  226.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 10/21.");
  227.         }
  228.         case 11:
  229.         {
  230.             ResetPlayerWeapons(playerid);
  231.             GivePlayerWeapon(playerid, 18, 20000);
  232.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 11/21.");
  233.         }
  234.         case 12:
  235.         {
  236.             ResetPlayerWeapons(playerid);
  237.             GivePlayerWeapon(playerid, 9, 1);
  238.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 12/21.");
  239.         }
  240.         case 13:
  241.         {
  242.             ResetPlayerWeapons(playerid);
  243.             GivePlayerWeapon(playerid, 37, 20000);
  244.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 13/21.");
  245.         }
  246.         case 14:
  247.         {
  248.             ResetPlayerWeapons(playerid);
  249.             GivePlayerWeapon(playerid, 38, 20000);
  250.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 14/21.");
  251.         }
  252.         case 15:
  253.         {
  254.             ResetPlayerWeapons(playerid);
  255.             GivePlayerWeapon(playerid, 35, 20000);
  256.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 15/21.");
  257.         }
  258.         case 16:
  259.         {
  260.             ResetPlayerWeapons(playerid);
  261.             GivePlayerWeapon(playerid, 36, 20000);
  262.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 16/21.");
  263.         }
  264.         case 17:
  265.         {
  266.             ResetPlayerWeapons(playerid);
  267.             GivePlayerWeapon(playerid, 39, 20000);
  268.             GivePlayerWeapon(playerid, 40, 1);
  269.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 17/21.");
  270.         }
  271.         case 18:
  272.         {
  273.             ResetPlayerWeapons(playerid);
  274.             GivePlayerWeapon(playerid, 41, 20000);
  275.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 18/21.");
  276.         }
  277.         case 19:
  278.         {
  279.             ResetPlayerWeapons(playerid);
  280.             GivePlayerWeapon(playerid, 42, 20000);
  281.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 19/21.");
  282.         }
  283.         case 20:
  284.         {
  285.             ResetPlayerWeapons(playerid);
  286.             GivePlayerWeapon(playerid, 4, 1);
  287.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 20/21.");
  288.         }
  289.         case 21:
  290.         {
  291.             ResetPlayerWeapons(playerid);
  292.             GivePlayerWeapon(playerid, 16, 3);
  293.             SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 21/21.");
  294.         }
  295.         case 22:
  296.         {
  297.             for(new i; i < MAX_PLAYERS; i++)
  298.             {
  299.                 if(!IsPlayerConnected(i)) return 0;
  300.                 TogglePlayerControllable(i,0);
  301.                 for(new bra=0; bra < 6; bra++)
  302.                 {
  303.                     new nach[128];
  304.                     format(nach, sizeof(nach), "Spieler %s hat diese Runde gewonnen!", spielerName(playerid));
  305.                     SendClientMessage(playerid,COLOR_GREEN, nach);
  306.                     SetTimerEx("RoundStart", 5000, 0, "i", playerid);
  307.                     TextDrawHideForAll(fuehrender);
  308.                 }
  309.             }
  310.         }
  311.     }
  312.     return 1;
  313. }
  314.  
  315. public OnPlayerDeath(playerid, killerid, reason)
  316. {
  317.     if(killerid == playerid)
  318.     {
  319.         SendClientMessage(playerid, COLOR_RED, "Du hast Selbstmord begangen, und hast somit ein Level verloren!");
  320.         SetPVarInt(playerid, "Level", GetPVarInt(playerid, "Level") - 1);
  321.     }
  322.     if(killerid != INVALID_PLAYER_ID)
  323.     {
  324.         if(reason != 53 || reason != 54)
  325.         {
  326.             SetPVarInt(killerid,"Level", GetPVarInt(killerid, "Level") + 1);
  327.             spielerSpeichern(killerid);
  328.             levelUp(killerid);
  329.         }
  330.     }
  331.     hoechstesLevel();
  332.     TextDrawHideForPlayer(playerid, fuehrender);
  333.     return 1;
  334. }
  335.  
  336. forward hoechstesLevel();
  337. public hoechstesLevel()
  338. {
  339.     new msg[128];
  340.     new pID, temp;
  341.     for(new i; i < MAX_PLAYERS; i++)
  342.     {
  343.         if((temp < GetPVarInt(i, "Level")))
  344.         {
  345.             temp = GetPVarInt(i, "Level"), pID = i;
  346.         }
  347.     }  
  348.     format(msg, sizeof(msg), "Fuehrender Spieler: %s Level: %i", spielerName(pID), temp);
  349.     TextDrawSetString(fuehrender, msg);
  350.     return 1;
  351. }
  352.  
  353. public OnVehicleSpawn(vehicleid)
  354. {
  355.     return 1;
  356. }
  357.  
  358. public OnVehicleDeath(vehicleid, killerid)
  359. {
  360.     return 1;
  361. }
  362.  
  363. public OnPlayerText(playerid, text[])
  364. {
  365.     return 1;
  366. }
  367.  
  368. public OnPlayerCommandText(playerid, cmdtext[])
  369. {
  370.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  371.     {
  372.         // Do something here
  373.         return 1;
  374.     }
  375.     return 0;
  376. }
  377.  
  378. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  379. {
  380.     return 1;
  381. }
  382.  
  383. public OnPlayerExitVehicle(playerid, vehicleid)
  384. {
  385.     return 1;
  386. }
  387.  
  388. public OnPlayerStateChange(playerid, newstate, oldstate)
  389. {
  390.     return 1;
  391. }
  392.  
  393. public OnPlayerEnterCheckpoint(playerid)
  394. {
  395.     return 1;
  396. }
  397.  
  398. public OnPlayerLeaveCheckpoint(playerid)
  399. {
  400.     return 1;
  401. }
  402.  
  403. public OnPlayerEnterRaceCheckpoint(playerid)
  404. {
  405.     return 1;
  406. }
  407.  
  408. public OnPlayerLeaveRaceCheckpoint(playerid)
  409. {
  410.     return 1;
  411. }
  412.  
  413. public OnRconCommand(cmd[])
  414. {
  415.     return 1;
  416. }
  417.  
  418. public OnPlayerRequestSpawn(playerid)
  419. {
  420.     return 1;
  421. }
  422.  
  423. public OnObjectMoved(objectid)
  424. {
  425.     return 1;
  426. }
  427.  
  428. public OnPlayerObjectMoved(playerid, objectid)
  429. {
  430.     return 1;
  431. }
  432.  
  433. public OnPlayerPickUpPickup(playerid, pickupid)
  434. {
  435.     return 1;
  436. }
  437.  
  438. public OnVehicleMod(playerid, vehicleid, componentid)
  439. {
  440.     return 1;
  441. }
  442.  
  443. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  444. {
  445.     return 1;
  446. }
  447.  
  448. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  449. {
  450.     return 1;
  451. }
  452.  
  453. public OnPlayerSelectedMenuRow(playerid, row)
  454. {
  455.     return 1;
  456. }
  457.  
  458. public OnPlayerExitedMenu(playerid)
  459. {
  460.     return 1;
  461. }
  462.  
  463. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  464. {
  465.     return 1;
  466. }
  467.  
  468. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  469. {
  470.     return 1;
  471. }
  472.  
  473. public OnRconLoginAttempt(ip[], password[], success)
  474. {
  475.     return 1;
  476. }
  477.  
  478. public OnPlayerUpdate(playerid)
  479. {
  480.     return 1;
  481. }
  482.  
  483. public OnPlayerStreamIn(playerid, forplayerid)
  484. {
  485.     return 1;
  486. }
  487.  
  488. public OnPlayerStreamOut(playerid, forplayerid)
  489. {
  490.     return 1;
  491. }
  492.  
  493. public OnVehicleStreamIn(vehicleid, forplayerid)
  494. {
  495.     return 1;
  496. }
  497.  
  498. public OnVehicleStreamOut(vehicleid, forplayerid)
  499. {
  500.     return 1;
  501. }
  502.  
  503. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  504. {
  505.     new path[128];
  506.     format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
  507.     switch(dialogid)
  508.     {
  509.         case DIALOG_REGIST1:
  510.         {
  511.             if(!response)
  512.             {
  513.                 Kick(playerid);
  514.             }
  515.             else
  516.             {
  517.                 new pwlength = strlen(inputtext);
  518.                 if(pwlength > 0)
  519.                 {
  520.                     new nachricht[238];
  521.                     format(nachricht, sizeof(nachricht), "Sie haben sich erfolgreich mit dem Namen %s registriert.", spielerName(playerid));
  522.                     dini_Create(path);
  523.                     dini_Set(path, "key", inputtext);
  524.                     dini_IntSet(path, "Level", 0);
  525.                     dini_IntSet(path, "banned", 0);
  526.                     dini_IntSet(path, "admin", 0);
  527.                     SendClientMessage(playerid, COLOR_TURKIS, nachricht);
  528.                     SendClientMessage(playerid, COLOR_TURKIS, "Das gesamte Team wünscht dir viel Spass beim spielen.");
  529.                     SendClientMessage(playerid, COLOR_TURKIS, "Solltest du Hilfe brauchen, gib /hilfe ein.");
  530.                 }
  531.                 else
  532.                 {
  533.                     ShowPlayerDialog(playerid, DIALOG_NOPW, DIALOG_STYLE_MSGBOX,"Registrierung" ,"Bitte geben Sie ein Passwort ein.", "Weiter", "Abbrechen");
  534.                 }
  535.             }
  536.         }
  537.         case DIALOG_LOGIN:
  538.         {
  539.             if(!response)
  540.             {
  541.                 Kick(playerid);
  542.             }
  543.             else
  544.             {
  545.                 new pwlength = strlen(inputtext);
  546.                 if(pwlength > 0)
  547.                 {
  548.                     new pw[200];
  549.                     format(pw,sizeof(pw), "%s", dini_Get(path, "key"));
  550.                     if(strcmp(inputtext, pw) == 0)
  551.                     {
  552.                         spielerLaden(playerid);
  553.                         SendClientMessage(playerid, COLOR_WHITE, "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
  554.                         SendClientMessage(playerid, COLOR_TURKIS, "Du hast dich erfolgreich eingeloggt!");
  555.                         SendClientMessage(playerid, COLOR_TURKIS, "Wir wünschen dir viel Spass beim spielen.");
  556.                         SendClientMessage(playerid, COLOR_WHITE, "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
  557.                     }
  558.                     else
  559.                     {
  560.                         ShowPlayerDialog(playerid, DIALOG_WRONGPW, DIALOG_STYLE_MSGBOX, "Login", "Falsches Passwort!", "OK", "Abbrechen");
  561.                     }
  562.                 }
  563.                 else
  564.                 {
  565.                     ShowPlayerDialog(playerid, DIALOG_NOPW2, DIALOG_STYLE_MSGBOX,  "Login", "Sie haben das falsche Passwort eingegeben.", "OK", "Abbrechen");
  566.                 }
  567.             }
  568.         }
  569.         case DIALOG_NOPW:
  570.         {
  571.             if(!response)
  572.             {
  573.                 Kick(playerid);
  574.             }
  575.             else
  576.             {
  577.                 ShowPlayerDialog(playerid, DIALOG_REGIST1, DIALOG_STYLE_PASSWORD,  "Registrierung", "Geben Sie hier Ihr gewuenschtes Passwort ein.", "OK",  "Abbrechen");
  578.             }
  579.         }
  580.         case DIALOG_NOPW2:
  581.         {
  582.             if(!response)
  583.             {
  584.                 Kick(playerid);
  585.             }
  586.             else
  587.             {
  588.                  ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Geben Sie Ihr Passwort ein.", "OK", "Abbrechen");
  589.             }
  590.         }
  591.         case DIALOG_WRONGPW:
  592.         {
  593.             if(!response)
  594.             {
  595.                 Kick(playerid);
  596.             }
  597.             else
  598.             {
  599.                  ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login", "Geben Sie hier Ihr Passwort ein.", "OK","Abbrechen");
  600.             }
  601.         }
  602.     }
  603.     return 1;
  604. }
  605.  
  606. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  607. {
  608.     new stats[258];
  609.     format(stats, sizeof(stats), "Spieler: %s [ID: %i], Level: %i, Spiele gewonnen: %i", spielerName(clickedplayerid), clickedplayerid, GetPVarInt(clickedplayerid, "Level"),GetPVarInt(clickedplayerid, "Gewonnen"));
  610.     SendClientMessage(playerid, COLOR_WHITE, stats);
  611.     return 1;
  612. }
  613.  
  614. ocmd:help(playerid,params[])
  615. {
  616.     SendClientMessage(playerid, COLOR_WHITE, "Was ist GunGame?");
  617.     SendClientMessage(playerid, COLOR_GREEN, "Gungame ist ein Mod, indem du deine Gegner mit");
  618.     SendClientMessage(playerid, COLOR_GREEN, "deiner Waffe töten musst, um eine neue Waffe zu bekommen.");
  619.     SendClientMessage(playerid, COLOR_GREEN, "Der erste Spieler, der Level 21 erreicht, gewinnt!");
  620.     SendClientMessage(playerid, COLOR_GREEN, "Solltest du Selbstmord begehen, verlierst du ein Level.");
  621.     SendClientMessage(playerid, COLOR_RED, "Dieser Gamemode wurde von DasNeo gescriptet.");
  622.     return 1;
  623. }
  624.  
  625. ocmd:kick(playerid,params[])
  626. {
  627.     if(GetPVarInt(playerid, "admin") == 1)
  628.     {
  629.         new id;
  630.         new reason[128];
  631.         if(sscanf(params,"us", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Benutzung: /kick [ID] [Grund]");
  632.         new sendMSG[278];
  633.         format(sendMSG,sizeof(sendMSG), "[AdmCMD - Kick] Spieler %s wurde gekickt. Begründung: %s", spielerName(id), reason);
  634.         SendClientMessageToAll(COLOR_RED, sendMSG);
  635.         new printMSG[278];
  636.         format(printMSG, sizeof(printMSG), "KICK: %s hat %s gekickt. Begründung: %s", spielerName(playerid), spielerName(id), reason);
  637.         print(printMSG);
  638.         Kick(id);
  639.     }
  640.     return 1;
  641. }
  642.  
  643. ocmd:rr(playerid,params[])
  644. {
  645.     if(GetPVarInt(playerid, "admin") == 1)
  646.     {
  647.         new sendMSG[278];
  648.         format(sendMSG,sizeof(sendMSG), "[AdmCMD - RoundRestart] Admin %s hat die Runde neu gestartet.", spielerName(playerid));
  649.         SendClientMessageToAll(COLOR_RED, sendMSG);
  650.         new printMSG[278];
  651.         format(printMSG, sizeof(printMSG), "RR: %s hat die Runde neu gestartet.", spielerName(playerid));
  652.         print(printMSG);
  653.     }
  654.     return 1;
  655. }
  656.  
  657. ocmd:ban(playerid,params[])
  658. {
  659.     if(GetPVarInt(playerid, "admin") == 1)
  660.     {
  661.         new id;
  662.         new reason[128];
  663.         if(sscanf(params,"us", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Benutzung: /ban [ID] [Grund]");
  664.         new sendMSG[278];
  665.         format(sendMSG,sizeof(sendMSG), "[AdmCMD - Ban] Spieler %s wurde gekickt. Begründung: %s", spielerName(id), reason);
  666.         SendClientMessageToAll(COLOR_RED, sendMSG);
  667.         new printMSG[278];
  668.         format(printMSG, sizeof(printMSG), "BAN: %s hat %s gekickt. Begründung: %s", spielerName(playerid), spielerName(id), reason);
  669.         print(printMSG);
  670.         SetPVarInt(id, "banned", 1);
  671.         spielerSpeichern(id);
  672.     }
  673.     return 1;
  674. }
  675.  
  676. stock sscanf(string[], format[], {Float,_}:...)
  677. {
  678.     #if defined isnull
  679.         if (isnull(string))
  680.     #else
  681.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  682.     #endif
  683.         {
  684.             return format[0];
  685.         }
  686.     #pragma tabsize 4
  687.     new
  688.         formatPos = 0,
  689.         stringPos = 0,
  690.         paramPos = 2,
  691.         paramCount = numargs(),
  692.         delim = ' ';
  693.     while (string[stringPos] && string[stringPos] <= ' ')
  694.     {
  695.         stringPos++;
  696.     }
  697.     while (paramPos < paramCount && string[stringPos])
  698.     {
  699.         switch (format[formatPos++])
  700.         {
  701.             case '\0':
  702.             {
  703.                 return 0;
  704.             }
  705.             case 'i', 'd':
  706.             {
  707.                 new
  708.                     neg = 1,
  709.                     num = 0,
  710.                     ch = string[stringPos];
  711.                 if (ch == '-')
  712.                 {
  713.                     neg = -1;
  714.                     ch = string[++stringPos];
  715.                 }
  716.                 do
  717.                 {
  718.                     stringPos++;
  719.                     if ('0' <= ch <= '9')
  720.                     {
  721.                         num = (num * 10) + (ch - '0');
  722.                     }
  723.                     else
  724.                     {
  725.                         return -1;
  726.                     }
  727.                 }
  728.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  729.                 setarg(paramPos, 0, num * neg);
  730.             }
  731.             case 'h', 'x':
  732.             {
  733.                 new
  734.                     num = 0,
  735.                     ch = string[stringPos];
  736.                 do
  737.                 {
  738.                     stringPos++;
  739.                     switch (ch)
  740.                     {
  741.                         case 'x', 'X':
  742.                         {
  743.                             num = 0;
  744.                             continue;
  745.                         }
  746.                         case '0' .. '9':
  747.                         {
  748.                             num = (num << 4) | (ch - '0');
  749.                         }
  750.                         case 'a' .. 'f':
  751.                         {
  752.                             num = (num << 4) | (ch - ('a' - 10));
  753.                         }
  754.                         case 'A' .. 'F':
  755.                         {
  756.                             num = (num << 4) | (ch - ('A' - 10));
  757.                         }
  758.                         default:
  759.                         {
  760.                             return -1;
  761.                         }
  762.                     }
  763.                 }
  764.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  765.                 setarg(paramPos, 0, num);
  766.             }
  767.             case 'c':
  768.             {
  769.                 setarg(paramPos, 0, string[stringPos++]);
  770.             }
  771.             case 'f':
  772.             {
  773.  
  774.                 new changestr[16], changepos = 0, strpos = stringPos;    
  775.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  776.                 {
  777.                     changestr[changepos++] = string[strpos++];
  778.                     }
  779.                 changestr[changepos] = '\0';
  780.                 setarg(paramPos,0,_:floatstr(changestr));
  781.             }
  782.             case 'p':
  783.             {
  784.                 delim = format[formatPos++];
  785.                 continue;
  786.             }
  787.             case '\'':
  788.             {
  789.                 new
  790.                     end = formatPos - 1,
  791.                     ch;
  792.                 while ((ch = format[++end]) && ch != '\'') {}
  793.                 if (!ch)
  794.                 {
  795.                     return -1;
  796.                 }
  797.                 format[end] = '\0';
  798.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  799.                 {
  800.                     if (format[end + 1])
  801.                     {
  802.                         return -1;
  803.                     }
  804.                     return 0;
  805.                 }
  806.                 format[end] = '\'';
  807.                 stringPos = ch + (end - formatPos);
  808.                 formatPos = end + 1;
  809.             }
  810.             case 'u':
  811.             {
  812.                 new
  813.                     end = stringPos - 1,
  814.                     id = 0,
  815.                     bool:num = true,
  816.                     ch;
  817.                 while ((ch = string[++end]) && ch != delim)
  818.                 {
  819.                     if (num)
  820.                     {
  821.                         if ('0' <= ch <= '9')
  822.                         {
  823.                             id = (id * 10) + (ch - '0');
  824.                         }
  825.                         else
  826.                         {
  827.                             num = false;
  828.                         }
  829.                     }
  830.                 }
  831.                 if (num && IsPlayerConnected(id))
  832.                 {
  833.                     setarg(paramPos, 0, id);
  834.                 }
  835.                 else
  836.                 {
  837.                     #if !defined foreach
  838.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  839.                         #define __SSCANF_FOREACH__
  840.                     #endif
  841.                     string[end] = '\0';
  842.                     num = false;
  843.                     new
  844.                         name[MAX_PLAYER_NAME];
  845.                     id = end - stringPos;
  846.                     foreach (Player, playerid)
  847.                     {
  848.                         GetPlayerName(playerid, name, sizeof (name));
  849.                         if (!strcmp(name, string[stringPos], true, id))
  850.                         {
  851.                             setarg(paramPos, 0, playerid);
  852.                             num = true;
  853.                             break;
  854.                         }
  855.                     }
  856.                     if (!num)
  857.                     {
  858.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  859.                     }
  860.                     string[end] = ch;
  861.                     #if defined __SSCANF_FOREACH__
  862.                         #undef foreach
  863.                         #undef __SSCANF_FOREACH__
  864.                     #endif
  865.                 }
  866.                 stringPos = end;
  867.             }
  868.             case 's', 'z':
  869.             {
  870.                 new
  871.                     i = 0,
  872.                     ch;
  873.                 if (format[formatPos])
  874.                 {
  875.                     while ((ch = string[stringPos++]) && ch != delim)
  876.                     {
  877.                         setarg(paramPos, i++, ch);
  878.                     }
  879.                     if (!i)
  880.                     {
  881.                         return -1;
  882.                     }
  883.                 }
  884.                 else
  885.                 {
  886.                     while ((ch = string[stringPos++]))
  887.                     {
  888.                         setarg(paramPos, i++, ch);
  889.                     }
  890.                 }
  891.                 stringPos--;
  892.                 setarg(paramPos, i, '\0');
  893.             }
  894.             default:
  895.             {
  896.                 continue;
  897.             }
  898.         }
  899.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  900.         {
  901.             stringPos++;
  902.         }
  903.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  904.         {
  905.             stringPos++;
  906.         }
  907.         paramPos++;
  908.     }
  909.     do
  910.     {
  911.         if ((delim = format[formatPos++]) > ' ')
  912.         {
  913.             if (delim == '\'')
  914.             {
  915.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  916.             }
  917.             else if (delim != 'z')
  918.             {
  919.                 return delim;
  920.             }
  921.         }
  922.     }
  923.     while (delim > ' ');
  924.     return 0;
  925. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement