Advertisement
BloodyEric

Untitled

Jun 26th, 2011
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.65 KB | None | 0 0
  1. #include <a_samp>
  2. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  3.  
  4. #define c4sellerx 1512.6119
  5. #define c4sellery -1460.3040
  6. #define c4sellerz 9.5000
  7. #define c4price 500
  8.  
  9. #define C4BUYDIALOG 20000
  10. #define C4LICDIALOG 20001 //layincar
  11. #define C4PLANTDIALOG 20002
  12.  
  13. forward Float:Distance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
  14.  
  15. public OnFilterScriptInit()
  16. {
  17.     printf("Bloodys C4-System geladen");
  18.     Create3DTextLabel("Ich bin der C4 Händler!\nBenutze /c4kaufen, um bei mir eine C4 zu kaufen!",0x00FF00FF,c4sellerx,c4sellery,c4sellerz,5,0,0);
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     SetPVarInt(playerid,"c4car",2500);
  25.     ApplyAnimation(playerid,"BOMBER","BOM_Plant",2.0,0,0,0,0,0);
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerCommandText(playerid, cmdtext[])
  30. {
  31.     dcmd(c4status,8,cmdtext);
  32.     dcmd(c4kaufen,8,cmdtext);
  33.     dcmd(c4legen,7,cmdtext);
  34.     dcmd(c4zuenden,9,cmdtext);
  35.     dcmd(c4nehmen,8,cmdtext);
  36.     dcmd(ac4geben,8,cmdtext);
  37.     dcmd(c4defuse,8,cmdtext);
  38.     dcmd(ac4entfernen,12,cmdtext);
  39.     dcmd(c4check,7,cmdtext);
  40.     dcmd(c4remove,8,cmdtext);
  41.     return 0;
  42. }
  43.  
  44. dcmd_c4status(playerid,params[])
  45. {
  46.     #pragma unused params
  47.     if(GetPVarInt(playerid,"c4counter")==0) return SendClientMessage(playerid,0x00FF00FF,"Du hast keine C4.");
  48.     else if(GetPVarInt(playerid,"c4counter")==1) return SendClientMessage(playerid,0x00FF00FF,"Du hast eine C4 dabei.");
  49.     else if (GetPVarInt(playerid,"c4counter")==2 || GetPVarInt(playerid,"c4counter")==3) return SendClientMessage(playerid,0x00FF00FF,"Du hast deine C4 schon platziert.");
  50.    
  51.     return 1;
  52. }
  53.  
  54. dcmd_c4kaufen(playerid,params[])
  55. {
  56.     #pragma unused params
  57.     if(IsPlayerInRangeOfPoint(playerid,5,c4sellerx,c4sellery,c4sellerz))
  58.     {
  59.         if(GetPVarInt(playerid,"c4counter")==0)
  60.         {
  61.             new tmpstr[180];
  62.             format(tmpstr,sizeof(tmpstr),"Möchtest du eine C4 kaufen? Ganz heiße Ware, damit sind früher Leute explodiert, die bei Fleischberg gegessen haben!\nDer Preis beträgt nur %d$!",c4price);
  63.             ShowPlayerDialog(playerid,C4BUYDIALOG,DIALOG_STYLE_MSGBOX,"Möchtest du eine C4 kaufen?",tmpstr,"Kaufen!","Lieber doch nicht");
  64.         }
  65.         else
  66.         {
  67.             SendClientMessage(playerid,0xFF0000,"Sorry, du hast schon eine C4..verknall erstmal die, Dude!");
  68.         }
  69.     }
  70.     return 1;
  71. }
  72. dcmd_c4legen(playerid,params[])
  73. {
  74.     #pragma unused params
  75.    
  76.     if(GetPVarInt(playerid,"c4counter")==0)
  77.         return SendClientMessage(playerid,0xFF0000FF,"Du hast keine C4 bei dir.");
  78.     else if(GetPVarInt(playerid,"c4counter")==2 || GetPVarInt(playerid,"c4counter")==3 )
  79.         return SendClientMessage(playerid,0xFF0000FF,"Du hast die C4 schon gelegt!");
  80.     //Ab diesem Punkt ist der Spieler befugt, eine C4 zu legen.
  81.     if(IsPlayerInAnyVehicle(playerid))
  82.         return ShowPlayerDialog(playerid,C4LICDIALOG,DIALOG_STYLE_MSGBOX,"C4 im Auto legen?","Du bist in einem Fahrzeug. Möchtest du die C4 in das Fahrzeug legen?","Ja","Nein");
  83.  
  84.     new Float:x;
  85.     new Float:y;
  86.     new Float:z;
  87.    
  88.     GetPlayerPos(playerid,x,y,z);
  89.     GetXYInFrontOfPlayer(playerid,x,y,0.7);
  90.     new objectid=CreateObject(1654,x,y,z-0.8,0,0,0);
  91.     SetPVarInt(playerid,"c4object",objectid);
  92.     SetPVarFloat(playerid,"c4x",x);
  93.     SetPVarFloat(playerid,"c4y",y);
  94.     SetPVarFloat(playerid,"c4z",z);
  95.     SetPVarInt(playerid,"c4counter",2);
  96.     ClearAnimations(playerid);
  97.     ApplyAnimation(playerid,"BOMBER","BOM_Plant",2.0,0,0,0,0,0);
  98.    
  99.     SendClientMessage(playerid,0x00FF00FF,"Die C4 wurde erfolgreich gelegt. Benutze /c4zuenden, damit es PUFF macht");
  100.    
  101.     return 1;
  102. }
  103. dcmd_c4zuenden(playerid,params[])
  104. {
  105.     #pragma unused params
  106.     if(GetPVarInt(playerid,"c4counter")==0)
  107.         return SendClientMessage(playerid,0xFF0000FF,"Du hast überhaupt keine C4, Trottel!");
  108.     if(GetPVarInt(playerid,"c4counter")==1)
  109.         return SendClientMessage(playerid,0xFF0000FF,"Du musst die C4 erstmal legen, Trottel!");
  110.     if(GetPVarInt(playerid,"c4counter")==3)
  111.     {
  112.         SetPVarInt(playerid,"c4counter",0);
  113.         return SendClientMessage(playerid,0xFF0000FF,"Fernzünder erfolgreich betätigt");
  114.     }
  115.     //Rausfinden, wo die C4 ist
  116.     new tmpcar=GetPVarInt(playerid,"c4car");
  117.     if(tmpcar!=2500) //Es wird ne Karre gesprengt..yes, baby!
  118.     {
  119.         new Float:x;
  120.         new Float:y;
  121.         new Float:z;
  122.         GetVehiclePos(tmpcar,x,y,z);
  123.         CreateExplosion(x,y,z,7,20.0); // <<<<Beste Zeile im Script
  124.         new Float:x2;
  125.         new Float:y2;
  126.         new Float:z2;
  127.         new objectid=GetPVarInt(playerid,"c4object");
  128.         DestroyObject(objectid);
  129.        
  130.         for(new i;i<MAX_VEHICLES;i++)
  131.         {
  132.             GetVehiclePos(i,x2,y2,z2);
  133.             new Float:d=Distance(x,y,z,x2,y2,z2);
  134.             if(d<=30) //Alles in der Umgebung soll mitrauchen
  135.             {
  136.                 new Float:newhealth;
  137.                 new Float:oldhealth;
  138.                 GetVehicleHealth(i,oldhealth);
  139.                 newhealth=oldhealth-(1100-(d*40));
  140.                 SetVehicleHealth(i,newhealth);
  141.             }
  142.         }
  143.         for(new l;l<MAX_PLAYERS;l++)
  144.         {
  145.             if(IsPlayerInRangeOfPoint(l,7,x,y,z))
  146.             {
  147.                 SetPlayerHealth(l,0.0);
  148.             }
  149.         }
  150.         SendClientMessage(playerid,0x00FF00FF,"Fernzünder erfolgreich betätigt");
  151.         SetPVarInt(playerid,"c4counter",0);
  152.         SetPVarFloat(playerid,"c4x",0);
  153.         SetPVarFloat(playerid,"c4y",0);
  154.         SetPVarFloat(playerid,"c4z",0);
  155.         SetPVarInt(playerid,"c4car",2500);
  156.         return 1;
  157.     }
  158.     else
  159.     {
  160.         new Float:x=GetPVarFloat(playerid,"c4x");
  161.         new Float:y=GetPVarFloat(playerid,"c4y");
  162.         new Float:z=GetPVarFloat(playerid,"c4z");
  163.    
  164.         if(x==0&&y==0&&z==0)
  165.             return SendClientMessage(playerid,0xFF0000FF,"FEHLERCODE 1337 LOL ZOMFG ROFL LMAO!!!!!");
  166.         //Code Copy%Paste 8)
  167.         CreateExplosion(x,y,z,7,20.0); // <<<<Beste Zeile im Script
  168.         new objectid=GetPVarInt(playerid,"c4object");
  169.         DestroyObject(objectid);
  170.  
  171.         new Float:x2;
  172.         new Float:y2;
  173.         new Float:z2;
  174.         for(new i;i<MAX_VEHICLES;i++)
  175.         {
  176.             GetVehiclePos(i,x2,y2,z2);
  177.             new Float:d=Distance(x,y,z,x2,y2,z2);
  178.             if(d<=30) //Alles in der Umgebung soll mitrauchen
  179.             {
  180.                 new Float:newhealth;
  181.                 new Float:oldhealth;
  182.                 GetVehicleHealth(i,oldhealth);
  183.                 newhealth=oldhealth-(1100-(d*40));
  184.                 SetVehicleHealth(i,newhealth);
  185.             }
  186.         }
  187.         for(new l;l<MAX_PLAYERS;l++)
  188.         {
  189.             if(IsPlayerInRangeOfPoint(l,7,x,y,z))
  190.             {
  191.                 SetPlayerHealth(l,0.0);
  192.             }
  193.         }
  194.         SendClientMessage(playerid,0x00FF00FF,"Fernzünder erfolgreich betätigt");
  195.         SetPVarInt(playerid,"c4counter",0);
  196.         SetPVarFloat(playerid,"c4x",0);
  197.         SetPVarFloat(playerid,"c4y",0);
  198.         SetPVarFloat(playerid,"c4z",0);
  199.         SetPVarInt(playerid,"c4car",2500);
  200.     }
  201.     return 1;
  202. }
  203. dcmd_c4nehmen(playerid,params[])
  204. {
  205.     #pragma unused params
  206.     if(GetPVarInt(playerid,"c4counter")==0)
  207.         return SendClientMessage(playerid,0xFF0000FF,"Du hast nichtmal nen Zünder, Trottel");
  208.     if(GetPVarInt(playerid,"c4counter")==1)
  209.         return SendClientMessage(playerid,0xFF0000FF,"Du hast deine C4 noch, Trottel");
  210.        
  211.     if(IsPlayerInAnyVehicle(playerid))
  212.     {
  213.         if(GetPlayerVehicleID(playerid)==GetPVarInt(playerid,"c4car"))
  214.         {
  215.             SetPVarInt(playerid,"c4counter",1);
  216.             SetPVarFloat(playerid,"c4x",0);
  217.             SetPVarFloat(playerid,"c4y",0);
  218.             SetPVarFloat(playerid,"c4z",0);
  219.             SetPVarInt(playerid,"c4car",2500);
  220.             SendClientMessage(playerid,0x00FF00FF,"Du hast dir deine C4 wieder genommen.");
  221.         }
  222.     }
  223.  
  224.     new Float:x;
  225.     new Float:y;
  226.     new Float:z;
  227.     new Float:x2=GetPVarFloat(playerid,"c4x");
  228.     new Float:y2=GetPVarFloat(playerid,"c4y");
  229.     new Float:z2=GetPVarFloat(playerid,"c4z");
  230.     GetPlayerPos(playerid,x,y,z);
  231.  
  232.     if(Distance(x,y,z,x2,y2,z2)<2.0)
  233.     {
  234.         new objectid=GetPVarInt(playerid,"c4object");
  235.         DestroyObject(objectid);
  236.         SetPVarInt(playerid,"c4counter",1);
  237.         SetPVarFloat(playerid,"c4x",0);
  238.         SetPVarFloat(playerid,"c4y",0);
  239.         SetPVarFloat(playerid,"c4z",0);
  240.         SetPVarInt(playerid,"c4car",2500);
  241.         SendClientMessage(playerid,0x00FF00FF,"Du hast dir deine C4 wieder genommen.");
  242.         return 1;
  243.     }
  244.     else
  245.     {
  246.         return SendClientMessage(playerid,0xFF0000FF,"Du bist bei keiner aufnehmbaren C4!");
  247.     }
  248. }
  249.  
  250. dcmd_ac4geben(playerid,params[]) //ADMINBEFEHL
  251. {
  252.     if(0==0)
  253.     {
  254.         new pid;
  255.         if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xFF0000FF,"Benutzung: /ac4geben SPIELER");
  256.         if(!IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFF0000FF,"Der angegebene Spieler ist nicht online!");
  257.         SetPVarInt(pid,"c4counter",1);
  258.         SendClientMessage(pid,0x00FF00FF,"Du hast nun eine C4!");
  259.         new tstr[MAX_PLAYER_NAME];
  260.         GetPlayerName(pid,tstr,sizeof(tstr));
  261.         new tstr2[128];
  262.         format(tstr2,sizeof(tstr2),"Du hast dem Spieler %s eine C4 gegeben!",tstr);
  263.         SendClientMessage(playerid,0x00FF00FF,tstr2);
  264.     }
  265.     return 1;
  266. }
  267. dcmd_c4defuse(playerid,params[])    //PD Befehl
  268. {
  269.     #pragma unused params
  270.     if(1==1) //TODO
  271.     {
  272.         if(IsPlayerInAnyVehicle(playerid))
  273.         {
  274.             new x=GetPlayerVehicleID(playerid);
  275.             for(new i;i<MAX_PLAYERS;i++)
  276.             {
  277.                 if(x==GetPVarInt(i,"c4car")&&GetPVarInt(i,"c4counter")==2)
  278.                 {
  279.                     new j=random(100);
  280.                     if(j<=25) //BOOOOM hrhr
  281.                     {
  282.                         new Float:x1;
  283.                         new Float:y1;
  284.                         new Float:z1;
  285.                         GetVehiclePos(x,x1,y1,z1);
  286.                         CreateExplosion(x1,y1,z1,7,20.0); // <<<<Beste Zeile im Script
  287.                         new objectid=GetPVarInt(i,"c4object");
  288.                         DestroyObject(objectid);
  289.  
  290.                         new Float:x2;
  291.                         new Float:y2;
  292.                         new Float:z2;
  293.                         for(new k;k<MAX_VEHICLES;k++)
  294.                         {
  295.                             GetVehiclePos(k,x2,y2,z2);
  296.                             new Float:d=Distance(x1,y1,z1,x2,y2,z2);
  297.                             if(d<=30) //Alles in der Umgebung soll mitrauchen
  298.                             {
  299.                                 new Float:newhealth;
  300.                                 new Float:oldhealth;
  301.                                 GetVehicleHealth(i,oldhealth);
  302.                                 newhealth=oldhealth-(1100-(d*40));
  303.                                 SetVehicleHealth(i,newhealth);
  304.                             }
  305.                         }
  306.                         for(new l;l<MAX_PLAYERS;l++)
  307.                         {
  308.                             if(IsPlayerInRangeOfPoint(l,7,x1,y1,z1))
  309.                             {
  310.                                 SetPlayerHealth(l,0.0);
  311.                             }
  312.                         }
  313.                         SetPVarInt(i,"c4counter",3);
  314.                         SetPVarFloat(i,"c4x",0);
  315.                         SetPVarFloat(i,"c4y",0);
  316.                         SetPVarFloat(i,"c4z",0);
  317.                         return SendClientMessage(playerid,0xFF0000FF,"Du hast den falschen Draht durchgeschnitten...shit happenz!");
  318.                     }
  319.                     else     //Not BOOM...aaawwww
  320.                     {
  321.                         SetPVarInt(i,"c4counter",3);
  322.                         SetPVarFloat(i,"c4x",0);
  323.                         SetPVarFloat(i,"c4y",0);
  324.                         SetPVarFloat(i,"c4z",0);
  325.                         return SendClientMessage(playerid,0x00FF00FF,"Du hast den richtigen Draht durchgeschnitten! Die C4 wurde entschärft!");
  326.                     }
  327.                 }//if pvarzeugs
  328.             }
  329.             return SendClientMessage(playerid,0xFF0000FF,"Du hast keine C4 in dem Fahrzeug gefunden.");
  330.         }
  331.         new Float:x;
  332.         new Float:y;
  333.         new Float:z;
  334.         GetPlayerPos(playerid,x,y,z);
  335.         for(new i;i<MAX_PLAYERS;i++)
  336.         {
  337.             if(GetPVarInt(i,"c4counter")==2)
  338.             {
  339.                 new Float:x1=GetPVarFloat(i,"c4x");
  340.                 new Float:y1=GetPVarFloat(i,"c4y");
  341.                 new Float:z1=GetPVarFloat(i,"c4z");
  342.                 if(Distance(x,y,z,x1,y1,z1)<2) //Boom oder nicht Boom, das ist hier die Frage!
  343.                 {
  344.                     new j=random(100);
  345.                     if(j<=25) //BOOOOM hrhr
  346.                     {
  347.                         CreateExplosion(x1,y1,z1,7,15.0); // <<<<Beste Zeile im Script
  348.                         new objectid=GetPVarInt(i,"c4object");
  349.                         DestroyObject(objectid);
  350.  
  351.                         new Float:x2;
  352.                         new Float:y2;
  353.                         new Float:z2;
  354.                         for(new k;k<MAX_VEHICLES;k++)
  355.                         {
  356.                             GetVehiclePos(k,x2,y2,z2);
  357.                             new Float:d=Distance(x1,y1,z1,x2,y2,z2);
  358.                             if(d<=30) //Alles in der Umgebung soll mitrauchen
  359.                             {
  360.                                 new Float:newhealth;
  361.                                 new Float:oldhealth;
  362.                                 GetVehicleHealth(i,oldhealth);
  363.                                 newhealth=oldhealth-(1100-(d*40));
  364.                                 SetVehicleHealth(i,newhealth);
  365.                             }
  366.                         }
  367.                         for(new l;l<MAX_PLAYERS;l++)
  368.                         {
  369.                             if(IsPlayerInRangeOfPoint(l,7,x1,y1,z1))
  370.                             {
  371.                                 SetPlayerHealth(l,0.0);
  372.                             }
  373.                         }
  374.                         SetPVarInt(i,"c4counter",3);
  375.                         SetPVarFloat(i,"c4x",0);
  376.                         SetPVarFloat(i,"c4y",0);
  377.                         SetPVarFloat(i,"c4z",0);
  378.                         return SendClientMessage(playerid,0xFF0000FF,"Du hast den falschen Draht durchgeschnitten...shit happenz!");
  379.                     }
  380.                     else     //Not BOOM...aaawwww
  381.                     {
  382.                         new objectid=GetPVarInt(i,"c4object");
  383.                         DestroyObject(objectid);
  384.                         SetPVarInt(i,"c4counter",3);
  385.                         SetPVarFloat(i,"c4x",0);
  386.                         SetPVarFloat(i,"c4y",0);
  387.                         SetPVarFloat(i,"c4z",0);
  388.                         return SendClientMessage(playerid,0x00FF00FF,"Du hast den richtigen Draht durchgeschnitten! Die C4 wurde entschärft!");
  389.                     }
  390.                 }
  391.             }
  392.         } //For Schleife
  393.         SendClientMessage(playerid,0xFF0000FF,"Du bist bei keiner C4");
  394.     }//NO COP
  395.  
  396.     return 1;
  397. }
  398.  
  399. dcmd_ac4entfernen(playerid,params[]) //ADMINBEFEHL
  400. {
  401.     if(0==0) //TODO
  402.     {
  403.         new pid;
  404.         if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xFF0000FF,"Benutzung: /ac4entfernen SPIELER");
  405.         if(!IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFF0000FF,"Der angegebene Spieler ist nicht online!");
  406.         if(GetPVarInt(pid,"c4counter")==0)
  407.             return SendClientMessage(playerid,0xFF0000FF,"Der Spieler hat gar keine C4");
  408.         else if(GetPVarInt(pid,"c4counter")==2)
  409.             return SendClientMessage(playerid,0xFF0000FF,"Der Spieler hat die C4 schon gelegt, sie ist nicht entfernbar.");
  410.         else if(GetPVarInt(pid,"c4counter")==3)
  411.             return SendClientMessage(playerid,0xFF0000FF,"Die C4 ist schon entschärft, der Spieler weiß dass nur noch nicht.");
  412.  
  413.         SetPVarInt(pid,"c4counter",0);
  414.         SetPVarFloat(pid,"c4x",0);
  415.         SetPVarFloat(pid,"c4y",0);
  416.         SetPVarFloat(pid,"c4z",0);
  417.         new tstr[MAX_PLAYER_NAME];
  418.         GetPlayerName(pid,tstr,sizeof(tstr));
  419.         new tstr2[128];
  420.         format(tstr2,sizeof(tstr2),"Du hast dem Spieler %s die C4 weggenommen!",tstr);
  421.         SendClientMessage(playerid,0x00FF00FF,tstr2);
  422.     }
  423.     return 1;
  424. }
  425. dcmd_c4check(playerid,params[])//PDBEFEHL
  426. {
  427.     if(0==0) //IsPlayerCop
  428.     {
  429.         new pid;
  430.         if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xFF0000FF,"Benutzung: /c4check SPIELER");
  431.         if(!IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFF0000FF,"Der angegebene Spieler ist nicht online.");
  432.         new Float:x;
  433.         new Float:y;
  434.         new Float:z;
  435.         GetPlayerPos(pid,x,y,z);
  436.         if(IsPlayerInRangeOfPoint(playerid,5,x,y,z))
  437.         {
  438.             switch(GetPVarInt(pid,"c4counter"))
  439.             {
  440.                 case 0: SendClientMessage(playerid,0x00FF00FF,"Der Spieler hat keine C4 bei sich.");
  441.                 case 1: SendClientMessage(playerid,0xFF0000FF,"Der Spieler hat eine C4 bei sich!");
  442.                 case 2..3: SendClientMessage(playerid,0x0000FFFF,"Du findest nur noch den Zünder beim Spieler.....");
  443.             }
  444.         }
  445.         else
  446.             SendClientMessage(playerid,0xFF0000FF,"Der Spieler ist zu weit weg!");
  447.     }
  448.     return 1;
  449. }
  450.  
  451. dcmd_c4remove(playerid,params[]) //PD BEFEHL
  452. {
  453.     if(0==0) //IsPlayerCop
  454.     {
  455.         new pid;
  456.         if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xFF0000FF,"Benutzung: /c4remove SPIELER");
  457.         if(!IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFF0000FF,"Der angegebene Spieler ist nicht verbunden.");
  458.         new Float:x;
  459.         new Float:y;
  460.         new Float:z;
  461.         GetPlayerPos(pid,x,y,z);
  462.         if(IsPlayerInRangeOfPoint(playerid,5,x,y,z))
  463.         {
  464.             switch(GetPVarInt(pid,"c4counter"))
  465.             {
  466.                 case 0: SendClientMessage(playerid,0xFF0000FF,"Der Spieler hat gar nix bei sich.");
  467.                 case 1:
  468.                 {
  469.                     SendClientMessage(pid,0x00FF00FF,"Ein Polizist hat dir die C4 weggenommen...das schöne Geld!");
  470.                     SendClientMessage(playerid,0x00FF00FF,"Du hast dem Spieler die C4 weggenommen");
  471.                     SetPVarInt(pid,"c4counter",0);
  472.                     SetPVarInt(pid,"c4car",2500);
  473.                     SetPVarFloat(pid,"c4x",0);
  474.                     SetPVarFloat(pid,"c4y",0);
  475.                     SetPVarFloat(pid,"c4z",0);
  476.                 }
  477.                 case 2..3:
  478.                 {
  479.                     SendClientMessage(pid,0xFF0000FF,"Ein Cop hat dir den Zünder abgenommen. Die Bombe ist damit nutzlos und verrotet. Shit happenz!");
  480.                     SendClientMessage(playerid,0x00FF00FF,"Du hast dem Spieler den Zünder abgenommen. Die Menschheit ist damit in letzter Sekunde gerettet worden!");
  481.                     new objectid=GetPVarInt(pid,"c4object");
  482.                     DestroyObject(objectid);
  483.                     SetPVarInt(pid,"c4counter",0);
  484.                     SetPVarInt(pid,"c4car",2500);
  485.                     SetPVarFloat(pid,"c4x",0);
  486.                     SetPVarFloat(pid,"c4y",0);
  487.                     SetPVarFloat(pid,"c4z",0);
  488.                 }
  489.  
  490.             }
  491.         }
  492.     }
  493.  
  494.     return 1;
  495. }
  496.  
  497.  
  498. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  499. {
  500.     switch(dialogid)
  501.     {
  502.         case C4BUYDIALOG:
  503.         {
  504.             if(response)
  505.             {
  506.                 new pmoney=GetPlayerMoney(playerid);
  507.                 if(pmoney<c4price) //GELDCHECK
  508.                 {
  509.                     SendClientMessage(playerid,0xFF0000FF,"Du Flachzange hast nicht genug Geld dabei...wolltest mich bescheißen, wa? Nich mit mir!");
  510.                     new Float:phealth;
  511.                     GetPlayerHealth(playerid,phealth);
  512.                     SetPlayerHealth(playerid,phealth-30.0);
  513.                     return 1;
  514.                 }
  515.                 if(GetPVarInt(playerid,"c4counter")!=0)
  516.                     return SendClientMessage(playerid,0xFF0000FF,"Exception 1338. Lauf solange du noch kannst...");
  517.                 SendClientMessage(playerid,0x00FF00FF,"Okay, hier ist das gute Stück...viel Spaß!");
  518.                 GivePlayerMoney(playerid,-c4price);
  519.             }
  520.         }
  521.         case C4LICDIALOG:
  522.         {
  523.             if(response)
  524.             {
  525.                 SendClientMessage(playerid,0x00FF00FF,"Du hast die C4 unterm Sitz versteckt. Sie ist SCHARF! Benutz den /c4zuenden, damits Puff macht!");
  526.                 SetPVarInt(playerid,"c4counter",2);
  527.                 SetPVarInt(playerid,"c4car",GetPlayerVehicleID(playerid));
  528.             }
  529.         }
  530.     }
  531.     return 0;
  532. }
  533.  
  534. stock Float:Distance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
  535. {
  536.     new Float:result = floatsqroot(floatpower(floatsub(x2,x1),2)+floatpower(floatsub(y2,y1),2)+floatpower(floatsub(z2,z1),2));
  537.     return result;
  538. }
  539.  
  540. stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
  541. {
  542.     new Float:a;
  543.  
  544.     GetPlayerPos(playerid, x2, y2, a);
  545.     GetPlayerFacingAngle(playerid, a);
  546.  
  547.     if(GetPlayerVehicleID(playerid))
  548.     {
  549.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  550.     }
  551.  
  552.     x2 += (distance * floatsin(-a, degrees));
  553.     y2 += (distance * floatcos(-a, degrees));
  554. }
  555.  
  556. /*----------------------------------------------------------------------------*-
  557. Function:
  558.     sscanf
  559. Params:
  560.     string[] - String to extract parameters from.
  561.     format[] - Parameter types to get.
  562.     {Float,_}:... - Data return variables.
  563. Return:
  564.     0 - Successful, not 0 - fail.
  565. Notes:
  566.     A fail is either insufficient variables to store the data or insufficient
  567.     data for the format string - excess data is disgarded.
  568.  
  569.     A string in the middle of the input data is extracted as a single word, a
  570.     string at the end of the data collects all remaining text.
  571.  
  572.     The format codes are:
  573.  
  574.     c - A character.
  575.     d, i - An integer.
  576.     h, x - A hex number (e.g. a colour).
  577.     f - A float.
  578.     s - A string.
  579.     z - An optional string.
  580.     pX - An additional delimiter where X is another character.
  581.     '' - Encloses a litteral string to locate.
  582.     u - User, takes a name, part of a name or an id and returns the id if they're connected.
  583.  
  584.     Now has IsNumeric integrated into the code.
  585.  
  586.     Added additional delimiters in the form of all whitespace and an
  587.     optioanlly specified one in the format string.
  588. -*----------------------------------------------------------------------------*/
  589.  
  590. stock sscanf(string[], format[], {Float,_}:...)
  591. {
  592.     #if defined isnull
  593.         if (isnull(string))
  594.     #else
  595.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  596.     #endif
  597.         {
  598.             return format[0];
  599.         }
  600.     #pragma tabsize 4
  601.     new
  602.         formatPos = 0,
  603.         stringPos = 0,
  604.         paramPos = 2,
  605.         paramCount = numargs(),
  606.         delim = ' ';
  607.     while (string[stringPos] && string[stringPos] <= ' ')
  608.     {
  609.         stringPos++;
  610.     }
  611.     while (paramPos < paramCount && string[stringPos])
  612.     {
  613.         switch (format[formatPos++])
  614.         {
  615.             case '\0':
  616.             {
  617.                 return 0;
  618.             }
  619.             case 'i', 'd':
  620.             {
  621.                 new
  622.                     neg = 1,
  623.                     num = 0,
  624.                     ch = string[stringPos];
  625.                 if (ch == '-')
  626.                 {
  627.                     neg = -1;
  628.                     ch = string[++stringPos];
  629.                 }
  630.                 do
  631.                 {
  632.                     stringPos++;
  633.                     if ('0' <= ch <= '9')
  634.                     {
  635.                         num = (num * 10) + (ch - '0');
  636.                     }
  637.                     else
  638.                     {
  639.                         return -1;
  640.                     }
  641.                 }
  642.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  643.                 setarg(paramPos, 0, num * neg);
  644.             }
  645.             case 'h', 'x':
  646.             {
  647.                 new
  648.                     num = 0,
  649.                     ch = string[stringPos];
  650.                 do
  651.                 {
  652.                     stringPos++;
  653.                     switch (ch)
  654.                     {
  655.                         case 'x', 'X':
  656.                         {
  657.                             num = 0;
  658.                             continue;
  659.                         }
  660.                         case '0' .. '9':
  661.                         {
  662.                             num = (num << 4) | (ch - '0');
  663.                         }
  664.                         case 'a' .. 'f':
  665.                         {
  666.                             num = (num << 4) | (ch - ('a' - 10));
  667.                         }
  668.                         case 'A' .. 'F':
  669.                         {
  670.                             num = (num << 4) | (ch - ('A' - 10));
  671.                         }
  672.                         default:
  673.                         {
  674.                             return -1;
  675.                         }
  676.                     }
  677.                 }
  678.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  679.                 setarg(paramPos, 0, num);
  680.             }
  681.             case 'c':
  682.             {
  683.                 setarg(paramPos, 0, string[stringPos++]);
  684.             }
  685.             case 'f':
  686.             {
  687.  
  688.                 new changestr[16], changepos = 0, strpos = stringPos;
  689.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  690.                 {
  691.                     changestr[changepos++] = string[strpos++];
  692.                     }
  693.                 changestr[changepos] = '\0';
  694.                 setarg(paramPos,0,_:floatstr(changestr));
  695.             }
  696.             case 'p':
  697.             {
  698.                 delim = format[formatPos++];
  699.                 continue;
  700.             }
  701.             case '\'':
  702.             {
  703.                 new
  704.                     end = formatPos - 1,
  705.                     ch;
  706.                 while ((ch = format[++end]) && ch != '\'') {}
  707.                 if (!ch)
  708.                 {
  709.                     return -1;
  710.                 }
  711.                 format[end] = '\0';
  712.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  713.                 {
  714.                     if (format[end + 1])
  715.                     {
  716.                         return -1;
  717.                     }
  718.                     return 0;
  719.                 }
  720.                 format[end] = '\'';
  721.                 stringPos = ch + (end - formatPos);
  722.                 formatPos = end + 1;
  723.             }
  724.             case 'u':
  725.             {
  726.                 new
  727.                     end = stringPos - 1,
  728.                     id = 0,
  729.                     bool:num = true,
  730.                     ch;
  731.                 while ((ch = string[++end]) && ch != delim)
  732.                 {
  733.                     if (num)
  734.                     {
  735.                         if ('0' <= ch <= '9')
  736.                         {
  737.                             id = (id * 10) + (ch - '0');
  738.                         }
  739.                         else
  740.                         {
  741.                             num = false;
  742.                         }
  743.                     }
  744.                 }
  745.                 if (num && IsPlayerConnected(id))
  746.                 {
  747.                     setarg(paramPos, 0, id);
  748.                 }
  749.                 else
  750.                 {
  751.                     #if !defined foreach
  752.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  753.                         #define __SSCANF_FOREACH__
  754.                     #endif
  755.                     string[end] = '\0';
  756.                     num = false;
  757.                     new
  758.                         name[MAX_PLAYER_NAME];
  759.                     id = end - stringPos;
  760.                     foreach (Player, playerid)
  761.                     {
  762.                         GetPlayerName(playerid, name, sizeof (name));
  763.                         if (!strcmp(name, string[stringPos], true, id))
  764.                         {
  765.                             setarg(paramPos, 0, playerid);
  766.                             num = true;
  767.                             break;
  768.                         }
  769.                     }
  770.                     if (!num)
  771.                     {
  772.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  773.                     }
  774.                     string[end] = ch;
  775.                     #if defined __SSCANF_FOREACH__
  776.                         #undef foreach
  777.                         #undef __SSCANF_FOREACH__
  778.                     #endif
  779.                 }
  780.                 stringPos = end;
  781.             }
  782.             case 's', 'z':
  783.             {
  784.                 new
  785.                     i = 0,
  786.                     ch;
  787.                 if (format[formatPos])
  788.                 {
  789.                     while ((ch = string[stringPos++]) && ch != delim)
  790.                     {
  791.                         setarg(paramPos, i++, ch);
  792.                     }
  793.                     if (!i)
  794.                     {
  795.                         return -1;
  796.                     }
  797.                 }
  798.                 else
  799.                 {
  800.                     while ((ch = string[stringPos++]))
  801.                     {
  802.                         setarg(paramPos, i++, ch);
  803.                     }
  804.                 }
  805.                 stringPos--;
  806.                 setarg(paramPos, i, '\0');
  807.             }
  808.             default:
  809.             {
  810.                 continue;
  811.             }
  812.         }
  813.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  814.         {
  815.             stringPos++;
  816.         }
  817.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  818.         {
  819.             stringPos++;
  820.         }
  821.         paramPos++;
  822.     }
  823.     do
  824.     {
  825.         if ((delim = format[formatPos++]) > ' ')
  826.         {
  827.             if (delim == '\'')
  828.             {
  829.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  830.             }
  831.             else if (delim != 'z')
  832.             {
  833.                 return delim;
  834.             }
  835.         }
  836.     }
  837.     while (delim > ' ');
  838.     return 0;
  839. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement