Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=-=-=-=-=-=-=-=-=-= DINAMICNO KREIRANJE PICKUPA BY SHOMY =-=-=-=-=-=-=-=-=-=//
- // = INCLUDE = //
- #include < a_samp >
- #include < YSI\y_ini >
- #include < YSI\y_commands >
- #include < sscanf2 >
- // = DEFINE = //
- #undef MAX_PICKUPS
- #define MAX_PICKUPS 250
- #define PFile "/Pickups/%d.ini"
- #define SCM SendClientMessage
- // = ENUM = //
- enum pInfo
- {
- Float:UlazX,
- Float:UlazY,
- Float:UlazZ,
- Float:IzlazX,
- Float:IzlazY,
- Float:IzlazZ,
- Model,
- pInterior,
- pText[80],
- BojaTexta
- }
- // = NEW = //
- new PickupInfo[MAX_PICKUPS][pInfo];
- new Text3D:label[sizeof(PickupInfo)];
- new ipickup,upickup,PravljeniPickupIzlaz,PravljeniPickup;
- // = PUBLICS = //
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_SECONDARY_ATTACK )
- {
- for(new i; i < MAX_PICKUPS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.5, PickupInfo[i][UlazX], PickupInfo[i][UlazY], PickupInfo[i][UlazZ]))
- {
- SetPlayerPos(playerid, PickupInfo[i][IzlazX], PickupInfo[i][IzlazY], PickupInfo[i][IzlazZ]);
- SetPlayerInterior(playerid, PickupInfo[i][pInterior]);
- }
- else if(IsPlayerInRangeOfPoint(playerid, 2.5, PickupInfo[i][IzlazX], PickupInfo[i][IzlazY], PickupInfo[i][IzlazZ]))
- {
- SetPlayerPos(playerid, PickupInfo[i][UlazX], PickupInfo[i][UlazY], PickupInfo[i][UlazZ]);
- SetPlayerInterior(playerid, 0);
- }
- }
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- for(new id = 0; id < sizeof(PickupInfo); id++)
- {
- new pFile[50];
- format(pFile, sizeof(pFile), PFile, id);
- if(fexist(pFile))
- {
- INI_ParseFile(pFile, "UcitajPickups", .bExtra = true, .extra = id);
- upickup = CreatePickup(PickupInfo[id][Model], 1, PickupInfo[id][UlazX], PickupInfo[id][UlazY], PickupInfo[id][UlazZ], -1);
- ipickup = CreatePickup(PickupInfo[id][Model], 1, PickupInfo[id][IzlazX], PickupInfo[id][IzlazY], PickupInfo[id][IzlazZ], -1);
- new str[80];
- format(str,sizeof(str), "%s", PickupInfo[id][pText]);
- label[upickup] = Create3DTextLabel(str, PickupInfo[PravljeniPickup][BojaTexta], PickupInfo[id][UlazX], PickupInfo[id][UlazY], PickupInfo[id][UlazZ], 10.0, 0, 0);
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pickupid == upickup) return 0;
- if(pickupid == ipickup) return 0;
- if(pickupid == PravljeniPickupIzlaz) return 0;
- return 1;
- }
- forward UcitajPickups(id, name[], value[]);
- public UcitajPickups(id, name[], value[])
- {
- INI_Float("Ulaz X", PickupInfo[id][UlazX]);
- INI_Float("Ulaz Y", PickupInfo[id][UlazY]);
- INI_Float("Ulaz Z", PickupInfo[id][UlazZ]);
- INI_Float("Izlaz X", PickupInfo[id][IzlazX]);
- INI_Float("Izlaz Y", PickupInfo[id][IzlazY]);
- INI_Float("Izlaz Z", PickupInfo[id][IzlazZ]);
- INI_Int("Model", PickupInfo[id][Model]);
- INI_Int("Interior", PickupInfo[id][pInterior]);
- INI_Int("Text", PickupInfo[id][pText]);
- INI_Int("Boja Texta", PickupInfo[id][BojaTexta]);
- return 1;
- }
- // = CMDS = //
- YCMD:kreirajpickup(playerid, params[], help)
- {
- #pragma unused help
- if(IsPlayerAdmin(playerid))
- {
- new model,text[80],inte,Float:iX,Float:iY,Float:iZ,Float:X,Float:Y,Float:Z,bt;
- if(sscanf(params, "ds[80]dfffd", model, text, bt, iX, iY, iZ, inte))
- {
- SCM(playerid, -1, "Koristite /kreirajpickup [Model] [Text] [Boja texta] [Izlaz X] [Izlaz Y] [Izlaz Z] [Interior]");
- SCM(playerid, -1, "Boja 1 - Bela || Boja 2 - Crvena || Boja 3 - Plava || Boja 4 - Narandzasta || Boja 5 - Roza");
- SCM(playerid, -1, "Boja 6 - Crna || Boja 7 - Zelena || Boja 8 - Ljubicasta || Boja 9 - Tamno Plava || Boja 10 - Zuta");
- }
- if(model > 19999 || model < 1) return SCM(playerid, -1, "Model ne moze biti manji od 1 ili veci od 19999");
- GetPlayerPos(playerid, X,Y,Z);
- PravljeniPickup = CreatePickup(model, 1, X,Y,Z, -1);
- new str[80];
- format(str,sizeof(str), "%s", text);
- if(bt < 1 || bt > 10) return SCM(playerid, -1, "Boja texta ne moze biti manji od 1 ili veci od 10 !");
- if(bt == 1) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFFFFFFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFFFFFFFF; }
- if(bt == 2) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF1414FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF1414FF; }
- if(bt == 3) { label[PravljeniPickup] = Create3DTextLabel(str, 0x6EF0FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x6EF0FFFF; }
- if(bt == 4) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF8000FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF8000FF; }
- if(bt == 5) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF0090FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF0090FF; }
- if(bt == 6) { label[PravljeniPickup] = Create3DTextLabel(str, 0x000000FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x000000FF; }
- if(bt == 7) { label[PravljeniPickup] = Create3DTextLabel(str, 0x09FF00FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x09FF00FF; }
- if(bt == 8) { label[PravljeniPickup] = Create3DTextLabel(str, 0x9900FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x9900FFFF; }
- if(bt == 9) { label[PravljeniPickup] = Create3DTextLabel(str, 0x0008FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x0008FFFF; }
- if(bt == 10) { label[PravljeniPickup] = Create3DTextLabel(str, 0xF2FF00FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xF2FF00FF; }
- PravljeniPickupIzlaz = CreatePickup(model, 1, iX,iY,iZ, -1);
- PickupInfo[PravljeniPickup][UlazX] = X;
- PickupInfo[PravljeniPickup][UlazY] = Y;
- PickupInfo[PravljeniPickup][UlazZ] = Z;
- PickupInfo[PravljeniPickup][IzlazX] = iX;
- PickupInfo[PravljeniPickup][IzlazY] = iY;
- PickupInfo[PravljeniPickup][IzlazZ] = iZ;
- PickupInfo[PravljeniPickup][Model] = model;
- PickupInfo[PravljeniPickup][pInterior] = inte;
- PickupInfo[PravljeniPickup][pText] = text;
- SavePickup(PravljeniPickup);
- }
- else return SCM(playerid, -1, "Niste RCON Admin !");
- return 1;
- }
- YCMD:movepickup(playerid, params[], help)
- {
- #pragma unused help
- if(IsPlayerAdmin(playerid))
- {
- new pFile[50], id, Float:iX,Float:iY,Float:iZ,Float:X,Float:Y,Float:Z, inte;
- if(sscanf(params, "dfffd", id, iX, iY, iZ, inte)) return SCM(playerid, -1, "Koristite /movepickup [ID] [Izlaz X] [Izlaz Y] [Izlaz Z] [Interior]");
- format(pFile,sizeof(pFile), PFile, id);
- if(fexist(pFile))
- {
- GetPlayerPos(playerid, X,Y,Z);
- DestroyPickup(id);
- Delete3DTextLabel(label[id]);
- PravljeniPickup = CreatePickup(PickupInfo[id][Model], 1, X,Y,Z, -1);
- new str[80];
- format(str,sizeof(str), "%s", PickupInfo[id][pText]);
- label[PravljeniPickup] = Create3DTextLabel(str, PickupInfo[PravljeniPickup][BojaTexta], X,Y,Z, 10.0, 0, 0);
- PravljeniPickupIzlaz = CreatePickup(PickupInfo[id][Model], 1, iX,iY,iZ, -1);
- PickupInfo[PravljeniPickup][UlazX] = X;
- PickupInfo[PravljeniPickup][UlazY] = Y;
- PickupInfo[PravljeniPickup][UlazZ] = Z;
- PickupInfo[PravljeniPickup][IzlazX] = iX;
- PickupInfo[PravljeniPickup][IzlazY] = iY;
- PickupInfo[PravljeniPickup][IzlazZ] = iZ;
- PickupInfo[PravljeniPickup][pInterior] = inte;
- SavePickup(PravljeniPickup);
- }
- else return SCM(playerid, -1, "Taj ID Pickupa ne postoji !");
- }
- else return SCM(playerid, -1, "Niste RCON Admin !");
- return 1;
- }
- YCMD:unistipickup(playerid, params[], help)
- {
- #pragma unused help
- if(IsPlayerAdmin(playerid))
- {
- new pFile[50], id, str[20];
- if(sscanf(params, "d", id)) return SCM(playerid, -1, "Koristite /unistipickup [ID]");
- format(pFile,sizeof(pFile), PFile, id);
- if(fexist(pFile))
- {
- fremove(pFile);
- DestroyPickup(id);
- Delete3DTextLabel(label[id]);
- format(str,sizeof(str), "Unistili ste pickup ID %d.", id);
- SCM(playerid, -1, str);
- }
- else return SCM(playerid, -1, "Taj ID Pickupa ne postoji !");
- }
- else return SCM(playerid, -1, "Niste RCON Admin !");
- return 1;
- }
- // = STOCK = //
- stock SavePickup(id)
- {
- new pFile[100];
- format(pFile,sizeof(pFile), PFile, id);
- new INI:File = INI_Open(pFile);
- INI_WriteFloat(File, "Ulaz X", PickupInfo[id][UlazX]);
- INI_WriteFloat(File, "Ulaz Y", PickupInfo[id][UlazY]);
- INI_WriteFloat(File, "Ulaz Z", PickupInfo[id][UlazZ]);
- INI_WriteFloat(File, "Izlaz X", PickupInfo[id][IzlazX]);
- INI_WriteFloat(File, "Izlaz Y", PickupInfo[id][IzlazY]);
- INI_WriteFloat(File, "Izlaz Z", PickupInfo[id][IzlazZ]);
- INI_WriteInt(File, "Model", PickupInfo[id][Model]);
- INI_WriteInt(File, "Interior", PickupInfo[id][pInterior]);
- INI_WriteInt(File, "Text", PickupInfo[id][pText]);
- INI_WriteInt(File, "Boja Texta", PickupInfo[id][BojaTexta]);
- INI_Close(File);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement