Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <sscanf>
- #define Public:%0(%1) \
- forward%0(%1); public%0(%1)
- native IsValidVehicle(vehicleid);
- new Text3D:Numar[MAX_VEHICLES];
- enum
- {
- DIALOG_PLATE
- }
- enum Plate
- {
- vText[35],
- vPersonal,
- }
- new PlateInfo[MAX_VEHICLES][Plate];
- main()
- {
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Plate system by Gireada loaded");
- print("--------------------------------------\n");
- LoadPlates();
- return 1;
- }
- CMD:setprot(playerid, params[])
- {
- if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii admin RCON");
- if(!(IsPlayerInAnyVehicle(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii intr-un vehicul");
- PlateInfo[GetPlayerVehicleID(playerid)][vPersonal] = 1;
- SendClientMessage(playerid, -1, "Ai pus protectie acestui vehicul");
- return 1;
- }
- CMD:setplate(playerid, params[])
- {
- new string[256];
- format(string, sizeof(string), "%s",PlateInfo[GetPlayerVehicleID(playerid)][vText]);
- SendClientMessage(playerid, -1, string);
- new loc = GetPlayerState(playerid);
- if(!(IsPlayerInAnyVehicle(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii intr-un vehicul");
- if(loc != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "Trebuie sa fii soferul");
- if(PlateInfo[GetPlayerVehicleID(playerid)][vPersonal] != 0) return SendClientMessage(playerid, -1, "Acest vehicul este protejat");
- ShowPlayerDialog(playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "Inmatriculare", "Introdu numarul de inmatriculare:", "Ok", "Anuleaza");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- switch(dialogid)
- {
- case DIALOG_PLATE:
- {
- if(!(response)) return SendClientMessage(playerid, -1, "Poate data viitoare");
- if(strlen(inputtext) > 30) return ShowPlayerDialog(playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "Inmatriculare", "Lungimea numarul trebuie sa fie de 30 de caractere maxim\nIntrodu numarul de inmatriculare:", "Ok", "Anuleaza");
- if(strlen(inputtext) <= 3) return ShowPlayerDialog(playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "Inmatriculare", "Lungimea numarul trebuie sa fie mai mare de 3 caractere\nIntrodu numarul de inmatriculare:", "Ok", "Anuleaza");
- format(PlateInfo[vehicleid][vText], 35, "%s",inputtext);
- PlateInfo[vehicleid][vPersonal] = 0;
- SavePlateCar(vehicleid);
- SetVehicleToRespawn(vehicleid);
- GetPlayerInVehicle(playerid, vehicleid);
- return 1;
- }
- }
- return 0;
- }
- public OnVehicleSpawn(vehicleid)
- {
- Delete3DTextLabel(Numar[vehicleid]);
- new file[20],numartxt[35],Float:x,Float:y,Float:z;
- format(file, sizeof(file),"Plates/%d.ini", vehicleid);
- GetVehiclePos(vehicleid, x,y,z);
- if(dini_Exists(file))
- {
- format(numartxt, sizeof(numartxt), "%d-%s",vehicleid,PlateInfo[vehicleid][vText]);
- Numar[vehicleid] = Create3DTextLabel(numartxt, 0xFFFFFFFF, x,y,z, 10.0, -1, 0);
- Attach3DTextLabelToVehicle(Numar[vehicleid], vehicleid, 0.0, 0.0, 0.0);
- SavePlateCar(vehicleid);
- }
- else if(!dini_Exists(file))
- {
- format(PlateInfo[vehicleid][vText], 35, "%d-GIR",vehicleid);
- format(numartxt, sizeof(numartxt), "%d-%s",vehicleid,PlateInfo[vehicleid][vText]);
- Numar[vehicleid] = Create3DTextLabel(numartxt, 0xFFFFFFFF, x,y,z, 10.0, -1, 0);
- Attach3DTextLabelToVehicle(Numar[vehicleid], vehicleid, 0.0, 0.0, 0.0);
- SavePlateCar(vehicleid);
- }
- return 1;
- }
- Public: SavePlateCar(vehicleid)
- {
- new file2[20];
- format(file2, sizeof(file2),"Plates/%d.ini", vehicleid);
- if(dini_Exists(file2))
- {
- dini_Set(file2,"Numar",PlateInfo[vehicleid][vText]);
- dini_IntSet(file2,"Personal",PlateInfo[vehicleid][vPersonal]);
- return 1;
- }
- else if(!dini_Exists(file2))
- {
- dini_Create(file2);
- dini_Set(file2,"Numar",PlateInfo[vehicleid][vText]);
- dini_IntSet(file2,"Personal",PlateInfo[vehicleid][vPersonal]);
- return 1;
- }
- return 1;
- }
- Public: LoadPlates()
- {
- new file2[20];
- for(new i = 1; i < MAX_VEHICLES; i++)
- {
- format(file2, sizeof(file2),"Plates/%d.ini", i);
- if(dini_Exists(file2))
- {
- PlateInfo[i][vPersonal] = dini_Int(file2,"Personal");
- format(PlateInfo[i][vText], 35, "%s",dini_Get(file2,"Numar"));
- }
- }
- return 1;
- }
- Public: GetPlayerInVehicle(playerid, vehicleid)
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid, x,y,z);
- SetVehiclePos(vehicleid, x,y,z);
- PutPlayerInVehicle(playerid, vehicleid, 0);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement