Guest User

Concessionaria by: AleeFerreira

a guest
Nov 26th, 2011
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #pragma tabsize 0
  4.  
  5. new proximocarro;
  6. new incar[MAX_PLAYERS];
  7. new string[256];
  8. #define MAX_CARROS 350
  9.  
  10. forward CriarVeiculo2(m,Float:x,Float:y,Float:z,Float:r,c,d);
  11. public CriarVeiculo2(m,Float:x,Float:y,Float:z,Float:r,c,d){
  12. format(string, sizeof(string), "carro%d.ini", proximocarro);
  13. new carroid;
  14. carroid = AddStaticVehicle(m, x, y, z, r, c, d);
  15. dini_IntSet(string, "Id", carroid);
  16. proximocarro++;
  17. }
  18. new STRX[256];
  19.  
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("\n--------------------------------------");
  24.     print(" Concessionaria by: Rodrigo");
  25.     print("--------------------------------------\n");
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36.     return 1;
  37. }
  38.  
  39. public OnPlayerDisconnect(playerid, reason)
  40. {
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerCommandText(playerid, cmdtext[])
  45. {
  46. new cmd[256];
  47. new idx;
  48. cmd = strtok(cmdtext, idx);
  49.  
  50.     if(strcmp(cmd, "/ccar", true) == 0) {
  51.         new pname[MAX_PLAYER_NAME];
  52.         GetPlayerName(playerid, pname, sizeof(pname));
  53.         if(IsPlayerAdmin(playerid)){
  54.  
  55.             new tmp[256];
  56.             new carid, Float:ang, preco, cor1, cor2;
  57.  
  58.             tmp = strtok(cmdtext, idx);
  59.             if(!strlen(tmp)){
  60.                 SendClientMessage(playerid, -1, "| ERRO | Veiculo inválido.");
  61.                 return 1;
  62.             }
  63.             carid = strval(tmp);
  64.  
  65.             tmp = strtok(cmdtext, idx);
  66.             if(!strlen(tmp)) {
  67.                 SendClientMessage(playerid, -1, "| ERRO |: /ccar [id] [preço] [cor1] [cor2]");
  68.                 return 1;
  69.             }
  70.             preco = strval(tmp);
  71.  
  72.             tmp = strtok(cmdtext, idx);
  73.             if(!strlen(tmp)) {
  74.                 SendClientMessage(playerid, -1, "| ERRO |: /ccar [id] [preço] [cor1] [cor2]");
  75.                 return 1;
  76.             }
  77.             cor1 = strval(tmp);
  78.  
  79.             tmp = strtok(cmdtext, idx);
  80.             if(!strlen(tmp)) {
  81.                 SendClientMessage(playerid, -1, "| ERRO |: /ccar [id] [preço] [cor1] [cor2]");
  82.                 return 1;
  83.             }
  84.             cor2 = strval(tmp);
  85.             if(carid >= 400 && carid <= 611){
  86.             if(IsPlayerInAnyVehicle(playerid)){
  87.                         new Float:X, Float:Y, Float:Z;
  88.                         GetPlayerPos(playerid, X, Y, Z);
  89.                         GetVehicleZAngle(GetPlayerVehicleID(playerid),ang);
  90.                         format(string, sizeof(string), "carro%d.ini", proximocarro);
  91.                         if(!dini_Exists(string)){
  92.                         dini_Create(string);
  93.                         dini_IntSet(string, "Modelo", carid);
  94.                         dini_FloatSet(string, "CordX", Float:X);
  95.                         dini_FloatSet(string, "CordY", Float:Y);
  96.                         dini_FloatSet(string, "CordZ", Float:Z);
  97.                         dini_FloatSet(string, "Angulo", Float:ang);
  98.                         dini_IntSet(string, "Cor1", cor1);
  99.                         dini_IntSet(string, "Cor2", cor2);
  100.                         dini_IntSet(string, "TDono", 0);
  101.                         dini_Set(string, "Dono", "Ninguem");
  102.                         dini_IntSet(string, "Preco", preco);
  103.                         }
  104.             SetTimerEx("CriarVeiculo2",5000,false,"dffffdd",carid,X,Y,Z,ang,cor1,cor2);
  105.                         format(string, sizeof(string), "[CamperLife]: Veiculo Criado e Salvo com sucesso!");
  106.                         SendClientMessage(playerid, -1, string);
  107.                         return 1;
  108.             } else {
  109.             SendClientMessage(playerid, -1, "[CamperLife]: Você não está em um veiculo!");
  110.             }
  111.             }
  112.             else{
  113.                 SendClientMessage(playerid, -1, "[CamperLife]: Erro ao criar o veiculo!");
  114.                 return 1;
  115.             }
  116.         } else {
  117.             SendClientMessage(playerid, -1, "| ERRO | Comando inválido!");
  118.             return 1;
  119.         }
  120.     }
  121.    
  122.     if(strcmp(cmdtext, "/comprarcarro", true) == 0) {
  123. new VehicleID;
  124. VehicleID = GetPlayerVehicleID(playerid);
  125. new pname[MAX_PLAYER_NAME];
  126. GetPlayerName(playerid, pname, sizeof(pname));
  127. for(new carro = 0; carro < MAX_CARROS; carro++)
  128. {
  129. format(string, sizeof(string), "carro%d.ini", carro);
  130. if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
  131. SendClientMessage(playerid, -1, "Você já tem um carro");
  132. return 1;
  133. }
  134. if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0 && VehicleID == dini_Int(string, "Id")){
  135. if(GetPlayerMoney(playerid) >= dini_Int(string, "Preco")){
  136. new aname[MAX_PLAYER_NAME];
  137. GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
  138. dini_IntSet(string, "TDono", 1);
  139. dini_Set(string, "Dono", aname);
  140. SendClientMessage(playerid, -1, "| INFO | Veiculo comprado com sucesso!");
  141. SendClientMessage(playerid, -1, "| INFO | Para ver os comandos do veiculo, use: /meucarro");
  142. GivePlayerMoney(playerid, -dini_Int(string, "Preco"));
  143. TogglePlayerControllable(playerid, 1);
  144. return 1;
  145. } else {
  146. SendClientMessage(playerid, -1, "| ERRO | Você não tem dinheiro suficiente!");
  147. return 1;
  148. }
  149. }
  150. }
  151. }
  152.  
  153.  
  154. if(strcmp(cmdtext, "/meucarro", true) == 0) {
  155. new pname[MAX_PLAYER_NAME];
  156. GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  157. new resultados;
  158. new string2[256];
  159. for(new carro = 0; carro < MAX_CARROS; carro++)
  160. {
  161. format(string, sizeof(string), "carro%d.ini", carro);
  162. if(dini_Exists(string)){
  163. if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
  164. format(string2, sizeof(string2), "Meu Carro(Id:%d)", carro);
  165. ShowPlayerDialog(playerid, 4501, DIALOG_STYLE_LIST, string, "Salvar Posição \nAlterar cor 1 \nAlterar cor 2 \nRespawnar Carro \nVender Carro", "OK", "Cancelar");
  166. resultados = 0;
  167. } else {
  168. resultados = 1;
  169. }
  170. }
  171. }
  172. if(resultados == 1){
  173. //SendClientMessage(playerid, -1, "Você não está no seu carro.");
  174. }
  175. return 1;
  176. }
  177.     return 0;
  178. }
  179.  
  180. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnPlayerExitVehicle(playerid, vehicleid)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnPlayerPickUpPickup(playerid, pickupid)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  196. {
  197. if(dialogid == 4501) // Menu
  198.             {
  199.             if(response)
  200.             {
  201.             if(listitem == 0) //Salvar posição
  202.             {
  203.             if(IsPlayerInAnyVehicle(playerid)){
  204.             new aname[MAX_PLAYER_NAME];
  205.             GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
  206.             new Float:carroX,Float:carroY,Float:carroZ,Float:carroA;
  207.             new vid;
  208.             vid = GetPlayerVehicleID(playerid);
  209.             GetVehiclePos(vid, carroX, carroY, carroZ);
  210.             GetVehicleZAngle(vid, carroA);
  211.             new pname[MAX_PLAYER_NAME];
  212.             GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  213.             for(new carro = 0; carro < MAX_CARROS; carro++)
  214.             {
  215.             format(string, sizeof(string), "carro%d.ini", carro);
  216.             if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
  217.             dini_FloatSet(string, "CordX", Float:carroX);
  218.             dini_FloatSet(string, "CordY", Float:carroY);
  219.             dini_FloatSet(string, "CordZ", Float:carroZ);
  220.             dini_FloatSet(string, "Angulo", Float:carroA);
  221.             //SendClientMessage(playerid, Verde, "Seu carro foi salvo na sua posição.");
  222.             }
  223.             }
  224.             SendClientMessage(playerid, -1, "Seu carro foi salvo na sua posição.");
  225.             } else {
  226.             SendClientMessage(playerid, -1, "Para salvar a posição você presisa estar em um carro.");
  227.             }
  228.             }
  229.             if(listitem == 1)    //Alterar cor 1
  230.             {
  231.             format(STRX, sizeof(STRX), "Alterar Cor 1\n\nDigite o número da cor desejada e aperte \"Alterar\".\n\n  ~ Domínio RPG!");
  232.             ShowPlayerDialog(playerid, 4502, DIALOG_STYLE_INPUT, "Meu Carro", STRX, "Alterar", "Cancelar");
  233.             }
  234.             if(listitem == 2)  //Alterar cor 2
  235.             {
  236.             format(STRX, sizeof(STRX), "Alterar Cor 2\n\nDigite o número da cor desejada e aperte \"Alterar\".\n\n  ~ Domínio RPG!");
  237.             ShowPlayerDialog(playerid, 4503, DIALOG_STYLE_INPUT, "Meu Carro", STRX, "Alterar", "Cancelar");
  238.             }
  239.             if(listitem == 3) // Respawnar carro
  240.             {
  241.             new pname[MAX_PLAYER_NAME];
  242.             GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  243.             for(new carro = 0; carro < MAX_CARROS; carro++)
  244.             {
  245.             format(string, sizeof(string), "carro%d.ini", carro);
  246.             if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
  247.             DestroyVehicle(dini_Int(string, "Id"));
  248.             new carroid;
  249.             carroid = AddStaticVehicle(dini_Int(string, "Modelo"), dini_Float(string, "CordX"), dini_Float(string, "CordY"), dini_Float(string, "CordZ"), dini_Float(string, "Angulo"), dini_Int(string, "Cor1"), dini_Int(string, "Cor2"));
  250.             dini_IntSet(string, "Id", carroid);
  251.             }
  252.             }
  253.             SendClientMessage(playerid, -1, "Carro respawnado !");
  254.             }
  255.             if(listitem == 4) // Vender carro
  256.             {
  257.             new pname[MAX_PLAYER_NAME];
  258.             GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  259.             for(new carro = 0; carro < MAX_CARROS; carro++)
  260.             {
  261.             format(string, sizeof(string), "carro%d.ini", carro);
  262.             if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
  263.             dini_Set(string, "Dono", "Nenhum");
  264.             dini_IntSet(string, "TDono", 0);
  265.             GivePlayerMoney(playerid, dini_Int(string, "Preco"));
  266.             }
  267.             }
  268.             }
  269.             }
  270.             }
  271. if(dialogid == 4502)
  272. {
  273. new nomepl[MAX_PLAYER_NAME];
  274. GetPlayerName(playerid, nomepl, sizeof(nomepl));
  275. if(response == 1)
  276. {
  277. new aname[MAX_PLAYER_NAME];
  278. GetPlayerName(playerid, aname, sizeof(aname));
  279. if(!IsNumeric(inputtext)){
  280. SendClientMessage(playerid, -1, "Valor inválido.");
  281. return 1;
  282. } else {
  283. for(new carro = 0; carro < MAX_CARROS; carro++)
  284. {
  285. format(string, sizeof(string), "carro%d.ini", carro);
  286. if(strcmp(dini_Get(string, "Dono"), aname, true) == 0){
  287. dini_IntSet(string, "Cor1", StrToInt(inputtext));
  288. ChangeVehicleColor(dini_Int(string, "Id"), dini_Int(string, "Cor1"), dini_Int(string, "Cor2"));
  289. }
  290. }
  291. }
  292. }
  293. }
  294. if(dialogid == 4503)
  295. {
  296. new nomepl[MAX_PLAYER_NAME];
  297. GetPlayerName(playerid, nomepl, sizeof(nomepl));
  298. if(response == 1)
  299. {
  300. new aname[MAX_PLAYER_NAME];
  301. GetPlayerName(playerid, aname, sizeof(aname));
  302. if(!IsNumeric(inputtext)){
  303. SendClientMessage(playerid, -1, "Valor inválido.");
  304. return 1;
  305. } else {
  306. for(new carro = 0; carro < MAX_CARROS; carro++)
  307. {
  308. format(string, sizeof(string), "carro%d.ini", carro);
  309. if(strcmp(dini_Get(string, "Dono"), aname, true) == 0){
  310. dini_IntSet(string, "Cor2", StrToInt(inputtext));
  311. ChangeVehicleColor(dini_Int(string, "Id"), dini_Int(string, "Cor1"), dini_Int(string, "Cor2"));
  312. }
  313. }
  314. }
  315. }
  316. }
  317.  
  318.     return 1;
  319. }
  320.  
  321. forward IsNumeric(const string[]);
  322. public IsNumeric(const string[])
  323. {
  324. for (new i = 0, j = strlen(string); i < j; i++) if (string[i] > '9' || string[i] < '0') return 0;
  325. return 1;
  326. }
  327.  
  328.  
  329.  
Advertisement
Add Comment
Please, Sign In to add comment