PDA

View Full Version : Problem with vehicle system


GuyYahood1
06/12/2013, 02:49 AM
Hello,

I try to do the player can tele his car by command: /CallCar
this command don't working some one can help me ?


#include <a_samp>
#include <cpstream>
#include <DOF2>
#pragma tabsize 0
#define COLOR_RED 0xFF0000FF
#define COLOR_ORANGE 0xFF9900FF
new CP_CShop;
public OnGameModeInit()
{
CP_CShop = CPS_AddCheckpoint(2795.5403,-1087.5466,30.7198,3.0,100);
return 1;
}
public OnPlayerConnect(playerid)
{
if(!fexist(PlayerFile(playerid)))
{
DOF2_CreateFile(PlayerFile(playerid));
DOF2_SetInt(PlayerFile(playerid),"CarID",-1);
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(CPS_IsPlayerInCheckpoint(playerid,CP_CShop))
{
new catstrcar[2500];
strcat(catstrcar,"{00FF00}Landstalker {FFFFFF}- 250,000$\n{00FF00}Bravura {FFFFFF}- 250,000$\n{00FF00}Buffalo {FFFFFF}- 500,000$\n{00FF00}Perenniel {FFFFFF}- 250,000$\n{00FF00}Sentinel {FFFFFF}- 250,000$\n{00FF00}Manana {FFFFFF}- 250,000$\n",2500);
strcat(catstrcar, "{00FF00}Voodoo {FFFFFF}- 250,000$\n{00FF00}Cheetah {FFFFFF}- 500,000$\n{00FF00}Esperanto {FFFFFF}- 250,000$\n{00FF00}Washington {FFFFFF}- 250,000$\n",2500);
strcat(catstrcar, "{00FF00}Bobcat {FFFFFF}- 250,000$\n{00FF00}BF Injection {FFFFFF}- 250,000$\n{00FF00}Premier {FFFFFF}- 250,000$\n{00FF00}Banshee {FFFFFF}- 1,000,000$\n{00FF00}Previon {FFFFFF}- 250,000$\n{00FF00}Stallion {FFFFFF}- 250,000$\n{00FF00}Monster {FFFFFF}- 400,000$\n",2500);
strcat(catstrcar, "{00FF00}Admiral {FFFFFF}- 250,000$\n{00FF00}Solair {FFFFFF}- 250,000$\n{00FF00}Glendale {FFFFFF}- 250,000$\n{00FF00}Oceanic {FFFFFF}- 250,000$\n{00FF00}Savana {FFFFFF}- 350,000$\n{00FF00}ZR-350 {FFFFFF}- 350,000$\n{00FF00}Hotring Racer {FFFFFF}- 500,000$\n{00FF00}Comet {FFFFFF}- 500,000$\n{00FF00}Super GT {FFFFFF}- 500,000$\n",2500);
strcat(catstrcar, "{00FF00}Turismo {FFFFFF}- 1,000,000$\n{00FF00}Infernus {FFFFFF}- 2,000,000$\n{00FF00}NRG-500 {FFFFFF}- 1,000,000$\n{00FF00}FCR-900 {FFFFFF}- 300,000$\n",2500);
strcat(catstrcar, "{00FF00}Bullet {FFFFFF}- 3,000,000$\n{00FF00}Bandito {FFFFFF}- 2,500,000$\n{00FF00}Patriot {FFFFFF}- 1,500,000$\n{00FF00}Quad {FFFFFF}- 750,000$\n",2500);
strcat(catstrcar, "{00FF00}BMX {FFFFFF}- 5,000,000$\n{00FF00}Mountain Bike {FFFFFF}- 2,500,000$\n{00FF00}FreeWay {FFFFFF}- 2,500,000$\n{00FF00}Remington {FFFFFF}- 1,750,000$\n",2500);
strcat(catstrcar, "{00FF00}Hustler {FFFFFF}- 2,000,000$\n{00FF00}Sultan {FFFFFF}- 6,500,000$\n{00FF00}Flash {FFFFFF}- 3,500,000$\n{00FF00}Huntley {FFFFFF}- 750,000$\n",2500);
strcat(catstrcar, "{00FF00}Club {FFFFFF}- 1,000,000$\n{00FF00}Phoenix {FFFFFF}- 2,500,000$\n{00FF00}Faggio {FFFFFF}- 4,500,000$\n{00FF00}FBI Rancher {FFFFFF}- 5,500,000$",2500);
ShowPlayerDialog(playerid,851,DIALOG_STYLE_LIST,"{FFFFFF}Cars",catstrcar,"קנייה","יציאה");
}
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 851)
{
if(!response) return true;
switch(listitem)
{
case 0: BuyVehicle(playerid, 250000, 400, "Landstalker");
case 1: BuyVehicle(playerid, 250000, 401, "Bravura");
case 2: BuyVehicle(playerid, 500000, 402, "Buffalo");
case 3: BuyVehicle(playerid, 250000, 404, "Perenniel");
case 4: BuyVehicle(playerid, 250000, 405, "Sentinel");
case 5: BuyVehicle(playerid, 250000, 410, "Manana");
case 6: BuyVehicle(playerid, 250000, 412, "Voodoo");
case 7: BuyVehicle(playerid, 500000, 415, "Cheetah");
case 8: BuyVehicle(playerid, 250000, 419, "Esperanto");
case 9: BuyVehicle(playerid, 250000, 421, "Washington");
case 10: BuyVehicle(playerid, 250000, 422, "Bobcat");
case 11: BuyVehicle(playerid, 250000, 424, "BF Injection");
case 12: BuyVehicle(playerid, 250000, 426, "Premier");
case 13: BuyVehicle(playerid, 1000000, 429, "Banshee");
case 14: BuyVehicle(playerid, 250000, 436, "Previon");
case 15: BuyVehicle(playerid, 250000, 439, "Stallion");
case 16: BuyVehicle(playerid, 400000, 444, "Monster");
case 17: BuyVehicle(playerid, 250000, 445, "Admiral");
case 18: BuyVehicle(playerid, 250000, 458, "Solair");
case 19: BuyVehicle(playerid, 250000, 466, "Glendale");
case 20: BuyVehicle(playerid, 250000, 467, "Oceanic");
case 21: BuyVehicle(playerid, 350000, 567, "Savana");
case 22: BuyVehicle(playerid, 350000, 477, "ZR-350");
case 23: BuyVehicle(playerid, 500000, 502, "Hotring Racer");
case 24: BuyVehicle(playerid, 500000, 480, "Comet");
case 25: BuyVehicle(playerid, 500000, 506, "Super GT");
case 26: BuyVehicle(playerid, 1000000, 451, "Turismo");
case 27: BuyVehicle(playerid, 2000000, 411, "Infernus");
case 28: BuyVehicle(playerid, 1000000, 522, "NRG-500");
case 29: BuyVehicle(playerid, 300000, 521, "FCR-900");
case 30: BuyVehicle(playerid, 3000000, 541, "Bullet");
case 31: BuyVehicle(playerid, 2500000, 568, "Bandito");
case 32: BuyVehicle(playerid, 1500000, 470, "Patriot");
case 33: BuyVehicle(playerid, 750000, 471, "Quad");
case 34: BuyVehicle(playerid, 5000000, 481, "BMX");
case 35: BuyVehicle(playerid, 2500000, 510, "Mountain Bike");
case 36: BuyVehicle(playerid, 2500000, 463, "FreeWay");
case 37: BuyVehicle(playerid, 1750000, 534, "Remington");
case 38: BuyVehicle(playerid, 2000000, 545, "Hustler");
case 39: BuyVehicle(playerid, 6500000, 560, "Sultan");
case 40: BuyVehicle(playerid, 3500000, 565, "Flash");
case 41: BuyVehicle(playerid, 750000, 579, "Huntley");
case 42: BuyVehicle(playerid, 1000000, 589, "Club");
case 43: BuyVehicle(playerid, 2500000, 603, "Phoenix");
case 44: BuyVehicle(playerid, 4500000, 462, "Faggio");
case 45: BuyVehicle(playerid, 5500000, 490, "FBI Rancher");
}
}
return 1;
}

stock BuyVehicle(playerid, price, vehicleid, const vname[])
{
new string[256],stringS[256];
if(GetPlayerMoney(playerid) < price) return SendClientMessage(playerid, COLOR_RED, "you dont have money");
GivePlayerMoney(playerid, -price);
for(new i=1; i<MAX_VEHICLES; i++)
{
if(!DOF2_FileExists(vFile(i)))
{
DOF2_CreateFile(vFile(i));
format(stringS,sizeof(stringS),vname);
DOF2_SetString(vFile(i),"Name",stringS);
DOF2_SetInt(vFile(i),"Model",vehicleid);
DOF2_SetInt(vFile(i),"Price",price);
DOF2_SetFloat(vFile(i), "X", 2477.0532);
DOF2_SetFloat(vFile(i), "Y", 1570.2543);
DOF2_SetFloat(vFile(i), "Z", 10.8203);
DOF2_SetFloat(vFile(i), "A",260.5233);
DOF2_SetInt(vFile(i),"Color1",0);
DOF2_SetInt(vFile(i),"Color2",0);
DOF2_SetString(vFile(i),"Owner",GetName(playerid));
DOF2_SetInt(vFile(i),"Nitro",0);
DOF2_SetInt(vFile(i),"Wheel",0);
DOF2_SetInt(vFile(i),"Hyd",0);
DOF2_SetInt(vFile(i),"Neon",0);
DOF2_SetInt(PlayerFile(playerid),"CarID",i);
}
}
CreateVehicle(vehicleid,DOF2_GetFloat(vFile(i),"X"),DOF2_GetFloat(vFile(i),"Y"),DOF2_GetFloat(vFile(i),"Z"),DOF2_GetFloat(vFile(i),"A"),0,0,-1);
return 1;
}

stock vFile(vehicleid)
{
new FileV[256];
format(FileV,sizeof(FileV),"/Cars/%d.ini", vehicleid);
return FileV;
}

stock GetName(playerid)
{
new name[24];
GetPlayerName(playerid,name,24);
return name;
}
stock PlayerFile(playerid)
{
new AAA[256];
format(AAA,sizeof(AAA),"/UsersA/%s.txt", GetName(playerid));
return AAA;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

if(!strcmp(cmdtext, "/CallCar", true) || !strcmp(cmdtext, "/CC", true))
{
PutPlayerInVehicle(playerid, DOF2_GetInt(PlayerFile(playerid),"CarID"), 0);
return 1;
}
return 0;
}

cessil
06/12/2013, 03:49 AM
just because you create a vehicle, doesn't mean it'll have the same id as it had last time

for example if there's no files called /Cars/1.ini, /Cars/2.ini and theres no vehicles on the server, but there is a /Cars/3.ini and you create it, it is now vehicleid 1

GuyYahood1
06/12/2013, 05:42 AM
But, how can I do it? Am I need open 46 files? and what am I write there?
There is a other way to do it that create a vehicle and you can called him and after GMX, you still can call the car. Thank you cessil.

GuyYahood1
06/12/2013, 01:38 PM
Up ?

GuyYahood1
07/12/2013, 12:08 AM
UP...?????