Advertisement
Gireada

Plate system 3D

Mar 3rd, 2014
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.54 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <zcmd>
  4. #include <sscanf>
  5.  
  6. #define Public:%0(%1) \
  7.     forward%0(%1); public%0(%1)
  8.    
  9. native IsValidVehicle(vehicleid);  
  10.  
  11. new Text3D:Numar[MAX_VEHICLES];
  12.  
  13. enum
  14. {
  15.     DIALOG_PLATE
  16. }  
  17.  
  18. enum Plate
  19. {
  20.     vText[35],
  21.     vPersonal,
  22. }
  23. new PlateInfo[MAX_VEHICLES][Plate];
  24.  
  25. main()
  26. {
  27. }
  28.  
  29. public OnFilterScriptInit()
  30. {
  31.     print("\n--------------------------------------");
  32.     print(" Plate system by Gireada loaded");
  33.     print("--------------------------------------\n");
  34.     LoadPlates();
  35.     return 1;
  36. }
  37.  
  38. CMD:setprot(playerid, params[])
  39. {
  40.     if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii admin RCON");
  41.     if(!(IsPlayerInAnyVehicle(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii intr-un vehicul");
  42.     PlateInfo[GetPlayerVehicleID(playerid)][vPersonal] = 1;
  43.     SendClientMessage(playerid, -1, "Ai pus protectie acestui vehicul");
  44.     return 1;
  45. }
  46.    
  47. CMD:setplate(playerid, params[])
  48. {
  49.     new string[256];
  50.     format(string, sizeof(string), "%s",PlateInfo[GetPlayerVehicleID(playerid)][vText]);
  51.     SendClientMessage(playerid, -1, string);
  52.     new loc = GetPlayerState(playerid);
  53.     if(!(IsPlayerInAnyVehicle(playerid))) return SendClientMessage(playerid, -1, "Trebuie sa fii intr-un vehicul");
  54.     if(loc != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "Trebuie sa fii soferul");
  55.     if(PlateInfo[GetPlayerVehicleID(playerid)][vPersonal] != 0) return SendClientMessage(playerid, -1, "Acest vehicul este protejat");
  56.     ShowPlayerDialog(playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "Inmatriculare", "Introdu numarul de inmatriculare:", "Ok", "Anuleaza");
  57.     return 1;
  58. }
  59.  
  60. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  61. {
  62.     new vehicleid = GetPlayerVehicleID(playerid);
  63.     switch(dialogid)
  64.     {
  65.         case DIALOG_PLATE:
  66.         {
  67.             if(!(response)) return SendClientMessage(playerid, -1, "Poate data viitoare");
  68.             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");
  69.             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");
  70.             format(PlateInfo[vehicleid][vText], 35, "%s",inputtext);
  71.             PlateInfo[vehicleid][vPersonal] = 0;
  72.             SavePlateCar(vehicleid);
  73.             SetVehicleToRespawn(vehicleid);
  74.             GetPlayerInVehicle(playerid, vehicleid);
  75.             return 1;
  76.         }
  77.     }  
  78.     return 0;
  79. }
  80.  
  81. public OnVehicleSpawn(vehicleid)
  82. {
  83.     Delete3DTextLabel(Numar[vehicleid]);
  84.     new file[20],numartxt[35],Float:x,Float:y,Float:z;
  85.     format(file, sizeof(file),"Plates/%d.ini", vehicleid);
  86.     GetVehiclePos(vehicleid, x,y,z);
  87.     if(dini_Exists(file))
  88.     {
  89.         format(numartxt, sizeof(numartxt), "%d-%s",vehicleid,PlateInfo[vehicleid][vText]);
  90.         Numar[vehicleid] = Create3DTextLabel(numartxt, 0xFFFFFFFF, x,y,z, 10.0, -1, 0);
  91.         Attach3DTextLabelToVehicle(Numar[vehicleid], vehicleid, 0.0, 0.0, 0.0);
  92.         SavePlateCar(vehicleid);
  93.     }
  94.     else if(!dini_Exists(file))
  95.     {
  96.         format(PlateInfo[vehicleid][vText], 35, "%d-GIR",vehicleid);
  97.         format(numartxt, sizeof(numartxt), "%d-%s",vehicleid,PlateInfo[vehicleid][vText]);
  98.         Numar[vehicleid] = Create3DTextLabel(numartxt, 0xFFFFFFFF, x,y,z, 10.0, -1, 0);
  99.         Attach3DTextLabelToVehicle(Numar[vehicleid], vehicleid, 0.0, 0.0, 0.0);
  100.         SavePlateCar(vehicleid);
  101.     }
  102.     return 1;
  103. }
  104.    
  105. Public: SavePlateCar(vehicleid)
  106. {
  107.     new file2[20];
  108.     format(file2, sizeof(file2),"Plates/%d.ini", vehicleid);
  109.     if(dini_Exists(file2))
  110.     {
  111.         dini_Set(file2,"Numar",PlateInfo[vehicleid][vText]);
  112.         dini_IntSet(file2,"Personal",PlateInfo[vehicleid][vPersonal]);
  113.         return 1;
  114.     }
  115.     else if(!dini_Exists(file2))
  116.     {
  117.         dini_Create(file2);
  118.         dini_Set(file2,"Numar",PlateInfo[vehicleid][vText]);
  119.         dini_IntSet(file2,"Personal",PlateInfo[vehicleid][vPersonal]);
  120.         return 1;
  121.     }
  122.     return 1;
  123. }  
  124.  
  125. Public: LoadPlates()
  126. {
  127.     new file2[20];
  128.     for(new i = 1; i < MAX_VEHICLES; i++)
  129.     {
  130.         format(file2, sizeof(file2),"Plates/%d.ini", i);
  131.         if(dini_Exists(file2))
  132.         {
  133.             PlateInfo[i][vPersonal] = dini_Int(file2,"Personal");
  134.             format(PlateInfo[i][vText], 35, "%s",dini_Get(file2,"Numar"));
  135.         }
  136.     }  
  137.     return 1;
  138. }
  139.  
  140. Public: GetPlayerInVehicle(playerid, vehicleid)
  141. {
  142.     new Float:x,Float:y,Float:z;
  143.     GetPlayerPos(playerid, x,y,z);
  144.     SetVehiclePos(vehicleid, x,y,z);
  145.     PutPlayerInVehicle(playerid, vehicleid, 0);
  146.     return 1;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement