Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SA-MP Filterscript
- *
- * (c) Copyright 2012, Kaliber
- *
- */
- #include <a_samp>
- #define COLOR_LIGHTRED 0xFF6347AA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTGREEN 0x7CFC00AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define Dialog0 921
- #define Dialog1 922
- #define Dialog2 923
- enum pInfo{
- Float:pX,
- Float:pY,
- Float:pZ,
- pworld,
- pModel,
- pType,
- };
- new Pickup[MAX_PICKUPS][pInfo];
- new pickupid[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- LoadPickups();
- print("\n\tCopyright (c) by Kaliber\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- stock SavePickup(string[])
- {
- new entry[256];
- format(entry, sizeof(entry), "%s\n",string);
- new File:hFile;
- hFile = fopen("pickups.cfg", io_append);
- fwrite(hFile, entry);
- fclose(hFile);
- }
- stock LoadPickups()
- {
- new arrCoords[30][64];
- new strFromFile2[256];
- new File: file = fopen("pickups.cfg", io_read);
- if (file)
- {
- new idx;
- while (idx < sizeof(Pickup))
- {
- fread(file, strFromFile2);
- split(strFromFile2, arrCoords, ',');
- Pickup[idx][pX] = floatstr(arrCoords[0]);
- Pickup[idx][pY] = floatstr(arrCoords[1]);
- Pickup[idx][pZ] = floatstr(arrCoords[2]);
- Pickup[idx][pworld] = strval(arrCoords[3]);
- Pickup[idx][pModel] = strval(arrCoords[4]);
- Pickup[idx][pType] = strval(arrCoords[5]);
- CreatePickup(Pickup[idx][pModel], Pickup[idx][pType], Pickup[idx][pX], Pickup[idx][pY], Pickup[idx][pZ], Pickup[idx][pworld]);
- idx++;
- }
- fclose(file);
- }
- return 1;
- }
- stock split(const strsrc[], strdest[][], delimiter)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc)){
- if(strsrc[i]==delimiter || i==strlen(strsrc)){
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- i++;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], idx, tmp[256];
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/createpickup", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Benutzung: /createpickup [modelid] [typid]");
- new typ, model;
- model = strval(tmp);
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Benutzung: /createpickup [modelid] [typid]");
- typ = strval(tmp);
- new Float: X, Float: Y, Float: Z, world;
- GetPlayerPos(playerid, X, Y, Z);
- world = GetPlayerVirtualWorld(playerid);
- CreatePickup(model, typ, X, Y, Z, world);
- for(new i; i<sizeof(Pickup); i++)
- {
- Pickup[i][pX] = X;
- Pickup[i][pY] = Y;
- Pickup[i][pZ] = Z;
- Pickup[i][pworld] = world;
- Pickup[i][pModel] = model;
- Pickup[i][pType] = typ;
- }
- new string[128];
- format(string, sizeof string,"%f, %f, %f, %d, %d, %d",X,Y,Z,world,model,typ);
- SavePickup(string);
- SendClientMessage(playerid, COLOR_LIGHTBLUE,"Pickup erfolgreich erstellt !");
- return 1;
- }
- if(strcmp(cmd, "/editpickup", true) == 0)
- {
- for(new i; i<sizeof(Pickup); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.0, Pickup[i][pX], Pickup[i][pY], Pickup[i][pZ]))
- {
- pickupid[playerid] = i;
- ShowPlayerDialog(playerid,Dialog0,DIALOG_STYLE_LIST,"{FF0000}Pickup System","{FFFFFF}Modelid\nType","Bestätigen","Abbrechen");
- return 1;
- }
- }
- return SendClientMessage(playerid, COLOR_LIGHTRED,"Du bist nicht in der Nähe von einem Pickup !");
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == Dialog0)
- {
- if(response == 1)
- {
- switch (listitem)
- {
- case 0:
- {
- ShowPlayerDialog(playerid,Dialog1,DIALOG_STYLE_INPUT,"{FF0000}Pickup System","{FFFFFF}Gib hier nun die {FF0000}Modelid{FFFFFF} ein:","Bestätigen","Abbrechen");
- }
- case 1:
- {
- ShowPlayerDialog(playerid,Dialog2,DIALOG_STYLE_INPUT,"{FF0000}Pickup System","{FFFFFF}Gib hier nun den {FF0000}Type{FFFFFF} ein:","Bestätigen","Abbrechen");
- }
- }
- }
- else
- {
- return 1;
- }
- }
- if(dialogid == Dialog1)
- {
- if(response == 1 && strval(inputtext) > 1)
- {
- DestroyPickup(pickupid[playerid]);
- CreatePickup(strval(inputtext), Pickup[pickupid[playerid]][pType], Pickup[pickupid[playerid]][pX], Pickup[pickupid[playerid]][pY], Pickup[pickupid[playerid]][pZ], Pickup[pickupid[playerid]][pworld]);
- SendClientMessage(playerid, COLOR_LIGHTBLUE,"Pickup erfolgreich editiert !");
- }
- else
- {
- return 1;
- }
- }
- if(dialogid == Dialog2)
- {
- if(response == 1 && strval(inputtext) > 1)
- {
- DestroyPickup(pickupid[playerid]);
- CreatePickup(Pickup[pickupid[playerid]][pModel], strval(inputtext), Pickup[pickupid[playerid]][pX], Pickup[pickupid[playerid]][pY], Pickup[pickupid[playerid]][pZ], Pickup[pickupid[playerid]][pworld]);
- SendClientMessage(playerid, COLOR_LIGHTBLUE,"Pickup erfolgreich editiert !");
- }
- else
- {
- return 1;
- }
- }
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment