Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.46 KB | None | 0 0
  1. /*
  2.     TheO´s Dynamic Weapons script
  3.     mit diesem Filterscript
  4.     könnt ihr Ingame mit einem
  5.     Befehl waffen Pickups erstellen
  6.     dieses Script dürft ihr edetieren
  7.     und Veröffentlichen sobald mein
  8.     Name drinn vorkommt "TheO"
  9.     (c) 2012 by Theo
  10.     Wer das Copyright löscht muss mit einem
  11.     Schlechten Gewissen weiter scripten...
  12.    
  13.     Mit freundlichen Grüßen
  14.  
  15.     TheO
  16.    
  17.     Erstellungs Datum: 2 August 2012
  18. */
  19.  
  20. #include <a_samp>
  21. #include <ocmd>
  22. #include <dini>
  23.  
  24. new wID[MAX_PLAYERS];
  25. new mun[MAX_PLAYERS];
  26.  
  27. #pragma unused ret_memcpy
  28. #pragma tabsize 0
  29.  
  30. #define MAX_WAFFEN 100 //Anpassen
  31.  
  32.  
  33. enum WeaponInfo
  34. {
  35.     Float:x,
  36.     Float:y,
  37.     Float:z,
  38.     Text3D:Label,
  39.     Pickup,
  40.     WeapID,
  41.     Mun
  42. }
  43.  
  44. new wInfo[MAX_WAFFEN][WeaponInfo];
  45.  
  46. public OnFilterScriptInit()
  47. {
  48.     print("\n--------------------------------------");
  49.     print(" Theo´s Dynamic Weapons sind geladen....");
  50.     print("--------------------------------------\n");
  51.  
  52.     for(new i =1; i < MAX_WAFFEN; i++)
  53.     {
  54.         LoadWaffen(i);
  55.     }
  56.     return true;
  57. }
  58.  
  59. public OnFilterScriptExit()
  60. {
  61.     for(new i = 1; i < MAX_WAFFEN; i++)
  62.     {
  63.         DestroyPickup(wInfo[i][Pickup]);
  64.         Delete3DTextLabel(wInfo[i][Label]);
  65.     }
  66.     return true;
  67. }
  68.  
  69.  
  70. public OnPlayerConnect(playerid)
  71. {
  72.     SendClientMessage(playerid,-1,"{FF0019}Dieses Script benutzt: Dynamic Weapons (c) by TheO");
  73.     return true;
  74. }
  75.  
  76. stock CreateWaffe(Float:X,Float:Y,Float:Z,WeaponID,Munni)
  77. {
  78.     new Wdatei[64];
  79.     for(new i = 1; i < MAX_WAFFEN; i++)
  80.     {
  81.         format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",i);
  82.         {
  83.             if(!fexist(Wdatei))
  84.             {
  85.                 dini_Create(Wdatei);
  86.                 dini_FloatSet(Wdatei,"PosX",X);
  87.                 dini_FloatSet(Wdatei,"PosY",Y);
  88.                 dini_FloatSet(Wdatei,"PosZ",Z);
  89.                 dini_IntSet(Wdatei,"WaffenID",WeaponID);
  90.                 dini_IntSet(Wdatei,"Munni",Munni);
  91.                 return LoadWaffen(i);
  92.             }
  93.         }
  94.     }
  95.     return true;
  96. }
  97.  
  98. stock LoadWaffen(waffenid)
  99. {
  100.     new Wdatei[64];
  101.     format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",waffenid);
  102.     if(!fexist(Wdatei))return 0;
  103.     wInfo[waffenid][x] = dini_Float(Wdatei,"PosX");
  104.     wInfo[waffenid][y] = dini_Float(Wdatei,"PosY");
  105.     wInfo[waffenid][z] = dini_Float(Wdatei,"PosZ");
  106.     wInfo[waffenid][WeapID] = dini_Int(Wdatei,"WaffenID");
  107.     wInfo[waffenid][Mun] = dini_Int(Wdatei,"Munni");
  108.     new WaffenName[64];
  109.     switch(wInfo[waffenid][WeapID])
  110.     {
  111.         case 0:{WaffenName="Text";}
  112.     }
  113.     new string[128];
  114.     format(string,sizeof(string),"{FF0019}WaffenPunkt\n {FFFFFF}WaffenId: {FFE600}%d \n{FFFFFF}Munnition: {FFE600}%d",wInfo[waffenid][WeapID],wInfo[waffenid][Mun]);
  115.     wInfo[waffenid][Label] = Create3DTextLabel(string,-1,wInfo[waffenid][x],wInfo[waffenid][y],wInfo[waffenid][z],20,0,0);
  116.     wInfo[waffenid][Pickup] = CreatePickup(1239,1,wInfo[waffenid][x],wInfo[waffenid][y],wInfo[waffenid][z],0);
  117.     return printf("Waffenid: %d wurde mit %d Munition geladen.",wInfo[waffenid][WeapID],wInfo[waffenid][Mun]);
  118. }
  119.  
  120. stock KillWaffen(wid)
  121. {
  122.     DestroyPickup(wInfo[wid][Pickup]);
  123.     return Delete3DTextLabel(wInfo[wid][Label]);
  124. }
  125.  
  126. ocmd:werstellen(playerid,params[])
  127. {
  128.     if(IsPlayerAdmin(playerid))
  129.     {
  130.         ShowPlayerDialog(playerid,4999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons ID","{FFFFFF}Bitte gebe hier die Waffen ID ein","Oke","Abbrechen");
  131.     }
  132.     return true;
  133. }
  134.  
  135. ocmd:wdelete(playerid,params[])
  136. {
  137.     if(IsPlayerAdmin(playerid))
  138.     {
  139.         for(new i = 0; i < MAX_WAFFEN; i++)
  140.         {
  141.             if(IsPlayerInRangeOfPoint(playerid,3,wInfo[i][x],wInfo[i][y],wInfo[i][z]))
  142.             {
  143.                 new Wdatei[64];
  144.                 format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",i);
  145.                 if(fexist(Wdatei))
  146.                 {
  147.                     dini_Remove(Wdatei);
  148.                     KillWaffen(i);
  149.                     SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Erfolgreich gelöscht.");
  150.                     return print("Waffe wurde gelöscht");
  151.                 }
  152.                
  153.             }
  154.         }
  155.     }
  156.     else
  157.     {
  158.         SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Diesen Befehl darfst du nicht Benutzen.");
  159.     }
  160.     return true;
  161. }
  162.  
  163.  
  164. public OnPlayerPickUpPickup(playerid, pickupid)
  165. {
  166.     for(new i = 1; i < MAX_WAFFEN; i++)
  167.     {
  168.         if(wInfo[i][Pickup] == pickupid)
  169.         {
  170.             if(GetPlayerWeapon(playerid) == wInfo[i][WeapID])
  171.             {
  172.                 SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Diese Waffe hast du bereits.");
  173.             }
  174.             else
  175.             {
  176.                 GivePlayerWeapon(playerid,wInfo[i][WeapID],wInfo[i][Mun]);
  177.                 new string[128];
  178.                 format(string,sizeof(string),"{FF0019}TheO sagt: {FFFFFF}Du erhälst die WaffenID: %d mit %d Munition",wInfo[i][WeapID],wInfo[i][Mun]);
  179.                 SendClientMessage(playerid,-1,string);
  180.             }
  181.         }
  182.     }
  183.     return true;
  184. }
  185.  
  186. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  187. {
  188.     if(dialogid == 4999)
  189.     {
  190.         if(response == 1)
  191.         {
  192.             if(!strlen(inputtext))
  193.             {
  194.                 SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Bitte gebe eine WaffenID ein oder Klicke Abrechen.");
  195.                 ShowPlayerDialog(playerid,4999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons ID","{FFFFFF}Bitte gebe hier die Waffen ID ein","Oke","Abbrechen");
  196.             }
  197.             else
  198.             {
  199.                 wID[playerid] = strval(inputtext);
  200.                 ShowPlayerDialog(playerid,3999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons Munni","{FFFFFF}Bitte gebe hier die Waffen Munition ein","Oke","Abbrechen");
  201.             }
  202.         }
  203.         else
  204.         {
  205.             return true;
  206.         }
  207.     }
  208.     if(dialogid == 3999)
  209.     {
  210.         if(response == 1)
  211.         {
  212.             if(!strlen(inputtext))
  213.             {
  214.                 SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Bitte gebe die Anzahl der Munition an oder Klicke Abrechen.");
  215.                 ShowPlayerDialog(playerid,3999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons Munni","{FFFFFF}Bitte gebe hier die Waffen Munition ein","Oke","Abbrechen");
  216.             }
  217.             else
  218.             {
  219.                 mun[playerid] = strval(inputtext);
  220.                 new Float:A,Float:B,Float:C;
  221.                 GetPlayerPos(playerid,A,B,C);
  222.                 CreateWaffe(A,B,C,wID[playerid],mun[playerid]);
  223.  
  224.             }
  225.         }
  226.         else
  227.         {
  228.             return true;
  229.         }
  230.     }
  231.     return true;
  232. }
  233.  
  234.  
  235.  
  236. stock sscanf(sstring[], format[], {Float,_}:...)
  237. {
  238.     #if defined isnull
  239.         if (isnull(sstring))
  240.     #else
  241.         if (sstring[0] == 0 || (sstring[0] == 1 && sstring[1] == 0))
  242.     #endif
  243.         {
  244.             return format[0];
  245.         }
  246.     #pragma tabsize 4
  247.     new
  248.         formatPos = 0,
  249.         sstringPos = 0,
  250.         paramPos = 2,
  251.         paramCount = numargs(),
  252.         delim = ' ';
  253.     while (sstring[sstringPos] && sstring[sstringPos] <= ' ')
  254.     {
  255.         sstringPos++;
  256.     }
  257.     while (paramPos < paramCount && sstring[sstringPos])
  258.     {
  259.         switch (format[formatPos++])
  260.         {
  261.             case '\0':
  262.             {
  263.                 return 0;
  264.             }
  265.             case 'i', 'd':
  266.             {
  267.                 new
  268.                     neg = 1,
  269.                     num = 0,
  270.                     ch = sstring[sstringPos];
  271.                 if (ch == '-')
  272.                 {
  273.                     neg = -1;
  274.                     ch = sstring[++sstringPos];
  275.                 }
  276.                 do
  277.                 {
  278.                     sstringPos++;
  279.                     if ('0' <= ch <= '9')
  280.                     {
  281.                         num = (num * 10) + (ch - '0');
  282.                     }
  283.                     else
  284.                     {
  285.                         return -1;
  286.                     }
  287.                 }
  288.                 while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
  289.                 setarg(paramPos, 0, num * neg);
  290.             }
  291.             case 'h', 'x':
  292.             {
  293.                 new
  294.                     num = 0,
  295.                     ch = sstring[sstringPos];
  296.                 do
  297.                 {
  298.                     sstringPos++;
  299.                     switch (ch)
  300.                     {
  301.                         case 'x', 'X':
  302.                         {
  303.                             num = 0;
  304.                             continue;
  305.                         }
  306.                         case '0' .. '9':
  307.                         {
  308.                             num = (num << 4) | (ch - '0');
  309.                         }
  310.                         case 'a' .. 'f':
  311.                         {
  312.                             num = (num << 4) | (ch - ('a' - 10));
  313.                         }
  314.                         case 'A' .. 'F':
  315.                         {
  316.                             num = (num << 4) | (ch - ('A' - 10));
  317.                         }
  318.                         default:
  319.                         {
  320.                             return -1;
  321.                         }
  322.                     }
  323.                 }
  324.                 while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
  325.                 setarg(paramPos, 0, num);
  326.             }
  327.             case 'c':
  328.             {
  329.                 setarg(paramPos, 0, sstring[sstringPos++]);
  330.             }
  331.             case 'f':
  332.             {
  333.  
  334.                 new changestr[16], changepos = 0, strpos = sstringPos;
  335.                 while(changepos < 16 && sstring[strpos] && sstring[strpos] != delim)
  336.                 {
  337.                     changestr[changepos++] = sstring[strpos++];
  338.                     }
  339.                 changestr[changepos] = '\0';
  340.                 setarg(paramPos,0,_:floatstr(changestr));
  341.             }
  342.             case 'p':
  343.             {
  344.                 delim = format[formatPos++];
  345.                 continue;
  346.             }
  347.             case '\'':
  348.             {
  349.                 new
  350.                     end = formatPos - 1,
  351.                     ch;
  352.                 while ((ch = format[++end]) && ch != '\'') {}
  353.                 if (!ch)
  354.                 {
  355.                     return -1;
  356.                 }
  357.                 format[end] = '\0';
  358.                 if ((ch = strfind(sstring, format[formatPos], false, sstringPos)) == -1)
  359.                 {
  360.                     if (format[end + 1])
  361.                     {
  362.                         return -1;
  363.                     }
  364.                     return 0;
  365.                 }
  366.                 format[end] = '\'';
  367.                 sstringPos = ch + (end - formatPos);
  368.                 formatPos = end + 1;
  369.             }
  370.             case 'u':
  371.             {
  372.                 new
  373.                     end = sstringPos - 1,
  374.                     id = 0,
  375.                     bool:num = true,
  376.                     ch;
  377.                 while ((ch = sstring[++end]) && ch != delim)
  378.                 {
  379.                     if (num)
  380.                     {
  381.                         if ('0' <= ch <= '9')
  382.                         {
  383.                             id = (id * 10) + (ch - '0');
  384.                         }
  385.                         else
  386.                         {
  387.                             num = false;
  388.                         }
  389.                     }
  390.                 }
  391.                 if (num && IsPlayerConnected(id))
  392.                 {
  393.                     setarg(paramPos, 0, id);
  394.                 }
  395.                 else
  396.                 {
  397.                     #if !defined foreach
  398.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  399.                         #define __SSCANF_FOREACH__
  400.                     #endif
  401.                     sstring[end] = '\0';
  402.                     num = false;
  403.                     new
  404.                         name[MAX_PLAYER_NAME];
  405.                     id = end - sstringPos;
  406.                     foreach (Player, playerid)
  407.                     {
  408.                         GetPlayerName(playerid, name, sizeof (name));
  409.                         if (!strcmp(name, sstring[sstringPos], true, id))
  410.                         {
  411.                             setarg(paramPos, 0, playerid);
  412.                             num = true;
  413.                             break;
  414.                         }
  415.                     }
  416.                     if (!num)
  417.                     {
  418.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  419.                     }
  420.                     sstring[end] = ch;
  421.                     #if defined __SSCANF_FOREACH__
  422.                         #undef foreach
  423.                         #undef __SSCANF_FOREACH__
  424.                     #endif
  425.                 }
  426.                 sstringPos = end;
  427.             }
  428.             case 's', 'z':
  429.             {
  430.                 new
  431.                     i = 0,
  432.                     ch;
  433.                 if (format[formatPos])
  434.                 {
  435.                     while ((ch = sstring[sstringPos++]) && ch != delim)
  436.                     {
  437.                         setarg(paramPos, i++, ch);
  438.                     }
  439.                     if (!i)
  440.                     {
  441.                         return -1;
  442.                     }
  443.                 }
  444.                 else
  445.                 {
  446.                     while ((ch = sstring[sstringPos++]))
  447.                     {
  448.                         setarg(paramPos, i++, ch);
  449.                     }
  450.                 }
  451.                 sstringPos--;
  452.                 setarg(paramPos, i, '\0');
  453.             }
  454.             default:
  455.             {
  456.                 continue;
  457.             }
  458.         }
  459.         while (sstring[sstringPos] && sstring[sstringPos] != delim && sstring[sstringPos] > ' ')
  460.         {
  461.             sstringPos++;
  462.         }
  463.         while (sstring[sstringPos] && (sstring[sstringPos] == delim || sstring[sstringPos] <= ' '))
  464.         {
  465.             sstringPos++;
  466.         }
  467.         paramPos++;
  468.     }
  469.     do
  470.     {
  471.         if ((delim = format[formatPos++]) > ' ')
  472.         {
  473.             if (delim == '\'')
  474.             {
  475.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  476.             }
  477.             else if (delim != 'z')
  478.             {
  479.                 return delim;
  480.             }
  481.         }
  482.     }
  483.     while (delim > ' ');
  484.     return 0;
  485. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement