Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- TheO´s Dynamic Weapons script
- mit diesem Filterscript
- könnt ihr Ingame mit einem
- Befehl waffen Pickups erstellen
- dieses Script dürft ihr edetieren
- und Veröffentlichen sobald mein
- Name drinn vorkommt "TheO"
- (c) 2012 by Theo
- Wer das Copyright löscht muss mit einem
- Schlechten Gewissen weiter scripten...
- Mit freundlichen Grüßen
- TheO
- Erstellungs Datum: 2 August 2012
- */
- #include <a_samp>
- #include <ocmd>
- #include <dini>
- new wID[MAX_PLAYERS];
- new mun[MAX_PLAYERS];
- #pragma unused ret_memcpy
- #pragma tabsize 0
- #define MAX_WAFFEN 100 //Anpassen
- enum WeaponInfo
- {
- Float:x,
- Float:y,
- Float:z,
- Text3D:Label,
- Pickup,
- WeapID,
- Mun
- }
- new wInfo[MAX_WAFFEN][WeaponInfo];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Theo´s Dynamic Weapons sind geladen....");
- print("--------------------------------------\n");
- for(new i =1; i < MAX_WAFFEN; i++)
- {
- LoadWaffen(i);
- }
- return true;
- }
- public OnFilterScriptExit()
- {
- for(new i = 1; i < MAX_WAFFEN; i++)
- {
- DestroyPickup(wInfo[i][Pickup]);
- Delete3DTextLabel(wInfo[i][Label]);
- }
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid,-1,"{FF0019}Dieses Script benutzt: Dynamic Weapons (c) by TheO");
- return true;
- }
- stock CreateWaffe(Float:X,Float:Y,Float:Z,WeaponID,Munni)
- {
- new Wdatei[64];
- for(new i = 1; i < MAX_WAFFEN; i++)
- {
- format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",i);
- {
- if(!fexist(Wdatei))
- {
- dini_Create(Wdatei);
- dini_FloatSet(Wdatei,"PosX",X);
- dini_FloatSet(Wdatei,"PosY",Y);
- dini_FloatSet(Wdatei,"PosZ",Z);
- dini_IntSet(Wdatei,"WaffenID",WeaponID);
- dini_IntSet(Wdatei,"Munni",Munni);
- return LoadWaffen(i);
- }
- }
- }
- return true;
- }
- stock LoadWaffen(waffenid)
- {
- new Wdatei[64];
- format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",waffenid);
- if(!fexist(Wdatei))return 0;
- wInfo[waffenid][x] = dini_Float(Wdatei,"PosX");
- wInfo[waffenid][y] = dini_Float(Wdatei,"PosY");
- wInfo[waffenid][z] = dini_Float(Wdatei,"PosZ");
- wInfo[waffenid][WeapID] = dini_Int(Wdatei,"WaffenID");
- wInfo[waffenid][Mun] = dini_Int(Wdatei,"Munni");
- new WaffenName[64];
- switch(wInfo[waffenid][WeapID])
- {
- case 0:{WaffenName="Text";}
- }
- new string[128];
- format(string,sizeof(string),"{FF0019}WaffenPunkt\n {FFFFFF}WaffenId: {FFE600}%d \n{FFFFFF}Munnition: {FFE600}%d",wInfo[waffenid][WeapID],wInfo[waffenid][Mun]);
- wInfo[waffenid][Label] = Create3DTextLabel(string,-1,wInfo[waffenid][x],wInfo[waffenid][y],wInfo[waffenid][z],20,0,0);
- wInfo[waffenid][Pickup] = CreatePickup(1239,1,wInfo[waffenid][x],wInfo[waffenid][y],wInfo[waffenid][z],0);
- return printf("Waffenid: %d wurde mit %d Munition geladen.",wInfo[waffenid][WeapID],wInfo[waffenid][Mun]);
- }
- stock KillWaffen(wid)
- {
- DestroyPickup(wInfo[wid][Pickup]);
- return Delete3DTextLabel(wInfo[wid][Label]);
- }
- ocmd:werstellen(playerid,params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid,4999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons ID","{FFFFFF}Bitte gebe hier die Waffen ID ein","Oke","Abbrechen");
- }
- return true;
- }
- ocmd:wdelete(playerid,params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- for(new i = 0; i < MAX_WAFFEN; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,3,wInfo[i][x],wInfo[i][y],wInfo[i][z]))
- {
- new Wdatei[64];
- format(Wdatei,sizeof(Wdatei),"/Weaps/Wpickup:%d.txt",i);
- if(fexist(Wdatei))
- {
- dini_Remove(Wdatei);
- KillWaffen(i);
- SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Erfolgreich gelöscht.");
- return print("Waffe wurde gelöscht");
- }
- }
- }
- }
- else
- {
- SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Diesen Befehl darfst du nicht Benutzen.");
- }
- return true;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- for(new i = 1; i < MAX_WAFFEN; i++)
- {
- if(wInfo[i][Pickup] == pickupid)
- {
- if(GetPlayerWeapon(playerid) == wInfo[i][WeapID])
- {
- SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Diese Waffe hast du bereits.");
- }
- else
- {
- GivePlayerWeapon(playerid,wInfo[i][WeapID],wInfo[i][Mun]);
- new string[128];
- format(string,sizeof(string),"{FF0019}TheO sagt: {FFFFFF}Du erhälst die WaffenID: %d mit %d Munition",wInfo[i][WeapID],wInfo[i][Mun]);
- SendClientMessage(playerid,-1,string);
- }
- }
- }
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 4999)
- {
- if(response == 1)
- {
- if(!strlen(inputtext))
- {
- SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Bitte gebe eine WaffenID ein oder Klicke Abrechen.");
- ShowPlayerDialog(playerid,4999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons ID","{FFFFFF}Bitte gebe hier die Waffen ID ein","Oke","Abbrechen");
- }
- else
- {
- wID[playerid] = strval(inputtext);
- ShowPlayerDialog(playerid,3999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons Munni","{FFFFFF}Bitte gebe hier die Waffen Munition ein","Oke","Abbrechen");
- }
- }
- else
- {
- return true;
- }
- }
- if(dialogid == 3999)
- {
- if(response == 1)
- {
- if(!strlen(inputtext))
- {
- SendClientMessage(playerid,-1,"{FF0019}TheO sagt: {FFFFFF}Bitte gebe die Anzahl der Munition an oder Klicke Abrechen.");
- ShowPlayerDialog(playerid,3999,DIALOG_STYLE_INPUT,"{C05723}t{FFFFFF}Dynamic Weapons Munni","{FFFFFF}Bitte gebe hier die Waffen Munition ein","Oke","Abbrechen");
- }
- else
- {
- mun[playerid] = strval(inputtext);
- new Float:A,Float:B,Float:C;
- GetPlayerPos(playerid,A,B,C);
- CreateWaffe(A,B,C,wID[playerid],mun[playerid]);
- }
- }
- else
- {
- return true;
- }
- }
- return true;
- }
- stock sscanf(sstring[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(sstring))
- #else
- if (sstring[0] == 0 || (sstring[0] == 1 && sstring[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- sstringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (sstring[sstringPos] && sstring[sstringPos] <= ' ')
- {
- sstringPos++;
- }
- while (paramPos < paramCount && sstring[sstringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = sstring[sstringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = sstring[++sstringPos];
- }
- do
- {
- sstringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = sstring[sstringPos];
- do
- {
- sstringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, sstring[sstringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = sstringPos;
- while(changepos < 16 && sstring[strpos] && sstring[strpos] != delim)
- {
- changestr[changepos++] = sstring[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(sstring, format[formatPos], false, sstringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- sstringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = sstringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = sstring[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- sstring[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - sstringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, sstring[sstringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- sstring[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- sstringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = sstring[sstringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = sstring[sstringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- sstringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (sstring[sstringPos] && sstring[sstringPos] != delim && sstring[sstringPos] > ' ')
- {
- sstringPos++;
- }
- while (sstring[sstringPos] && (sstring[sstringPos] == delim || sstring[sstringPos] <= ' '))
- {
- sstringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement