SA-MP Forums Archive
Dynamic car system help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dynamic car system help (/showthread.php?tid=603951)



Dynamic car system help - justjamie - 29.03.2016

Hello!
So i got this dynamic car system from the internet, and it works perfectly, but i want to add a command that adds custom plates that save, but have no idea how to do it.
(It's DINI btw)
Can someone help me?


Re: Dynamic car system help - justjamie - 29.03.2016

A normal car file looks like this
The name is CarID (like car1)
Код:
model=522
x=1841.415039
y=-1510.924682
z=13.642996
a=246.328521
color1=108
color2=108
nitro=1
paintjob=-1
carteam=0
cartype=0
modeltype=3
biznumber=0
vw=0
jobname=None
owner=NoBodY
dupekey=NoBodY
price=0
resetted=0
components=0,0,0,0,0,0,0,0,0,0,0,0,0,0



Re: Dynamic car system help - Skimmer - 29.03.2016

Can you show us which system do you use? So send us at least the link where you got the dynamic script from.


Re: Dynamic car system help - justjamie - 29.03.2016

Quote:
Originally Posted by Skimmer
Посмотреть сообщение
Can you show us which system do you use? So send us at least the link where you got the dynamic script from.
It's a script i bought, so i can only show snippets.

here is a snippet, if you don't have enough from only that tell me.
pawn Код:
if(tmpid!=-1 && biz[tmpid][biztype]==21)
        {
            format(nomefile,sizeof(nomefile),"%s.txt",biz[tmpid][bizname]);
            {
                if(GetPlayerCars(playerid) >= 4 && PlayerInfo[playerid][premium] == 0)
                {
                    return SendClientError(playerid, "Sorry, you have no slots left! You may donate to get more slots!");
                }
                if(GetPlayerCars(playerid) >= 6)
                {
                    return SendClientError(playerid, "Sorry, you have no slots left!");
                }
                if(dini_Int(nomefile, "comps") <= 0) return SendClientError(playerid, "No cars in stock!");
                if(PlayerTemp[playerid][sm] < jobcars[listitem][jcprice]) return SendClientError(playerid, "Not enough cash!");
                new carid = GetUnusedCar();
                if(carid == -1) return SendClientWarning(playerid, "Error occured, please report the problem. (F8)");

                new
                    string[ 128 ];

                format(string, sizeof(string), "Dealership: You have bought a %s for $%s! Enter it and park it! (/car help)", jobcars[listitem][jcname], number_format(jobcars[listitem][jcprice]));
                SendClientInfo(playerid, string);

                GivePlayerMoneyEx(playerid, -jobcars[listitem][jcprice]);
                dini_IntSet(nomefile,"bizcash",dini_Int(nomefile,"bizcash") + jobcars[listitem][jcprice]/2);
                dini_IntSet(nomefile,"comps", dini_Int(nomefile, "comps") - 1);

                UnModCar(carid);
                // 1705.0454,-1475.6901,13.1665,169.0701
                //2838.0874,,,
                dini_FloatSet(CarFile(carid), "x", 1859.228637);
                dini_FloatSet(CarFile(carid), "y", -1849.452026);
                dini_FloatSet(CarFile(carid), "z", 13.579807);
                dini_FloatSet(CarFile(carid), "a", 8.9621);
                dini_IntSet(CarFile(carid), "resetted", 0);
                dini_IntSet(CarFile(carid), "cartype", 0);
                dini_IntSet(CarFile(carid), "carteam", 0);
                dini_IntSet(CarFile(carid), "model", jobcars[listitem][jcmodel]);
                dini_Set(CarFile(carid), "owner", PlayerName(playerid));
                ReloadVehicle(carid);
                PutPlayerInVehicle(playerid, carid, 0);

                format(string, sizeof(string), "6[VEHICLE] %s has bought a %s for $%s from the %s!", PlayerName(playerid), GetVehicleName(GetPlayerVehicleID(playerid)), number_format(jobcars[listitem][jcprice]), biz[tmpid][bizname]);
                iEcho(string);
                return 1;
            }
        }
    }



Re: Dynamic car system help - Skimmer - 29.03.2016

You can save the plate number by using this line.
pawn Код:
dini_Set(CarFile(carid), "plate", "Any plate number");
And load it by using this line.
pawn Код:
dini_Set(CarFile(carid), "plate", "Any plate number");

SetVehicleNumberPlate(vehicleId, dini_Get(CarFile(cardid), "plate"));
Since I don't know where you are using the save vehicle script.

Hope I could help you a lot.


Re: Dynamic car system help - justjamie - 29.03.2016

Quote:
Originally Posted by Skimmer
Посмотреть сообщение
You can save the plate number by using this line.
pawn Код:
dini_Set(CarFile(carid), "plate", "Any plate number");
And load it by using this line.
pawn Код:
dini_Set(CarFile(carid), "plate", "Any plate number");

SetVehicleNumberPlate(vehicleId, dini_Get(CarFile(cardid), "plate"));
Since I don't know where you are using the save vehicle script.

Hope I could help you a lot.
Thats kinda what i want, but i want a command that changes the plate.
This is my load vehicles script, can you maybe change it in and make a command, if it isn't that much effort :3.
Here is the load vehicles thing.
pawn Код:
stock LoadVehicle(i)
{
    Vehicles[i][carmodel] = dini_Int(CarFile(i), "model");
    Vehicles[i][fx] = dini_Float(CarFile(i), "x");
    Vehicles[i][fy] = dini_Float(CarFile(i), "y");
    Vehicles[i][fz] = dini_Float(CarFile(i), "z");
    Vehicles[i][fa] = dini_Float(CarFile(i), "a");
    Vehicles[i][color1] = dini_Int(CarFile(i), "color1");
    Vehicles[i][color2] = dini_Int(CarFile(i), "color2");
    Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
    Vehicles[i][paintjob] = dini_Int(CarFile(i), "paintjob");
    Vehicles[i][carteam] = dini_Int(CarFile(i), "carteam");
    Vehicles[i][cartype] = dini_Int(CarFile(i), "cartype");
    Vehicles[i][modeltype] = dini_Int(CarFile(i), "modeltype");
    Vehicles[i][biznumber] = dini_Int(CarFile(i), "biznumber");
    Vehicles[i][reset] = dini_Int(CarFile(i), "resetted");
    Vehicles[i][vw] = dini_Int(CarFile(i), "vw");
    Vehicles[i][carprice] = dini_Int(CarFile(i), "price");
    myStrcpy(Vehicles[i][jobname], dini_Get(CarFile(i), "jobname"));
    myStrcpy(Vehicles[i][carowner],dini_Get(CarFile(i), "owner"));
    myStrcpy(Vehicles[i][dupekey],dini_Get(CarFile(i), "dupekey"));
    sscanf(dini_Get(CarFile(i), "components"), "p<,>iiiiiiiiiiiiii",
                Vehicles[i][Components][0],
                Vehicles[i][Components][1],
                Vehicles[i][Components][2],
                Vehicles[i][Components][3],
                Vehicles[i][Components][4],
                Vehicles[i][Components][5],
                Vehicles[i][Components][6],
                Vehicles[i][Components][7],
                Vehicles[i][Components][8],
                Vehicles[i][Components][9],
                Vehicles[i][Components][10],
                Vehicles[i][Components][11],
                Vehicles[i][Components][12],
                Vehicles[i][Components][13]
            );
    SetTimerEx("ModCar", 2000, 0, "d", i);
    if(Vehicles[i][carprice] == -1)
    {
        dini_IntSet(CarFile(i), "price", 0);
        Vehicles[i][carprice] = 0;
    }
    new __a = CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    SetVehicleVirtualWorld(__a, Vehicles[i][vw]);
    if(Vehicles[i][carprice]) UnlockVehicle(i);
    format(iStr, sizeof(iStr), "{d30404}LS - {000000}%d", i);
    SetVehicleNumberPlate(i, iStr);
    SetVehicleToRespawn(i);
}



Re: Dynamic car system help - Pottus - 29.03.2016

If you actually paid money for that you got ripped off.


Re: Dynamic car system help - Mencent - 29.03.2016

Hi!

PHP код:
stock LoadVehicle(i)
{
    
Vehicles[i][carmodel] = dini_Int(CarFile(i), "model");
    
Vehicles[i][fx] = dini_Float(CarFile(i), "x");
    
Vehicles[i][fy] = dini_Float(CarFile(i), "y");
    
Vehicles[i][fz] = dini_Float(CarFile(i), "z");
    
Vehicles[i][fa] = dini_Float(CarFile(i), "a");
    
Vehicles[i][color1] = dini_Int(CarFile(i), "color1");
    
Vehicles[i][color2] = dini_Int(CarFile(i), "color2");
    
Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
    
Vehicles[i][paintjob] = dini_Int(CarFile(i), "paintjob");
    
Vehicles[i][carteam] = dini_Int(CarFile(i), "carteam");
    
Vehicles[i][cartype] = dini_Int(CarFile(i), "cartype");
    
Vehicles[i][modeltype] = dini_Int(CarFile(i), "modeltype");
    
Vehicles[i][biznumber] = dini_Int(CarFile(i), "biznumber");
    
Vehicles[i][reset] = dini_Int(CarFile(i), "resetted");
    
Vehicles[i][vw] = dini_Int(CarFile(i), "vw");
    
Vehicles[i][carprice] = dini_Int(CarFile(i), "price");
    
myStrcpy(Vehicles[i][jobname], dini_Get(CarFile(i), "jobname"));
    
myStrcpy(Vehicles[i][carowner],dini_Get(CarFile(i), "owner"));
    
myStrcpy(Vehicles[i][dupekey],dini_Get(CarFile(i), "dupekey"));
    
myStrcpy(Vehicles[i][numberplate],dini_Get(CarFile(i),"numberplate"));
    
sscanf(dini_Get(CarFile(i), "components"), "p<,>iiiiiiiiiiiiii",
    
Vehicles[i][Components][0],
    
Vehicles[i][Components][1],
    
Vehicles[i][Components][2],
    
Vehicles[i][Components][3],
    
Vehicles[i][Components][4],
    
Vehicles[i][Components][5],
    
Vehicles[i][Components][6],
    
Vehicles[i][Components][7],
    
Vehicles[i][Components][8],
    
Vehicles[i][Components][9],
    
Vehicles[i][Components][10],
    
Vehicles[i][Components][11],
    
Vehicles[i][Components][12],
    
Vehicles[i][Components][13]);
    
SetTimerEx("ModCar"20000"d"i);
    if(
Vehicles[i][carprice] == -1)
    {
        
dini_IntSet(CarFile(i), "price"0);
        
Vehicles[i][carprice] = 0;
    }
    new 
__a CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    
SetVehicleVirtualWorld(__aVehicles[i][vw]);
    if(
Vehicles[i][carprice]) UnlockVehicle(i);
    
format(iStrsizeof(iStr), "{d30404}LS - {000000}%d"i);
    
SetVehicleNumberPlate(iiStr);
    
SetVehicleToRespawn(i);
}
//When you buy a car:
dini_FloatSet(CarFile(carid), "x"1859.228637);
dini_FloatSet(CarFile(carid), "y", -1849.452026);
dini_FloatSet(CarFile(carid), "z"13.579807);
dini_FloatSet(CarFile(carid), "a"8.9621);
dini_IntSet(CarFile(carid), "resetted"0);
dini_IntSet(CarFile(carid), "cartype"0);
dini_IntSet(CarFile(carid), "carteam"0);
dini_IntSet(CarFile(carid), "model"jobcars[listitem][jcmodel]);
dini_Set(CarFile(carid), "owner"PlayerName(playerid));
new 
plate[12];
format(plate,sizeof(plate),"{d30404}LS - {000000}%d",carid);
dini_Set(CarFile(carid),"numberplate",plate);
ReloadVehicle(carid);
//The command (in OnPlayerCommandText; you can change the command processor):
if(!strcmp(cmdtext,"/cnplate",true))
{
    new 
plate[12];
    if(
sscanf(cmdtext,"s[12]",plate))return SendClientMessage(playerid,-1,"/cnplate [number plate]");
    
//Here you can go on

You have to go on with the command. You have to check if the player is in a vehicle and so on. Also you have to set the number plate of the vehicle (maybe you have to check if the player is the owner of this car).


Re: Dynamic car system help - justjamie - 29.03.2016

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hi!

PHP код:
stock LoadVehicle(i)
{
    
Vehicles[i][carmodel] = dini_Int(CarFile(i), "model");
    
Vehicles[i][fx] = dini_Float(CarFile(i), "x");
    
Vehicles[i][fy] = dini_Float(CarFile(i), "y");
    
Vehicles[i][fz] = dini_Float(CarFile(i), "z");
    
Vehicles[i][fa] = dini_Float(CarFile(i), "a");
    
Vehicles[i][color1] = dini_Int(CarFile(i), "color1");
    
Vehicles[i][color2] = dini_Int(CarFile(i), "color2");
    
Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
    
Vehicles[i][paintjob] = dini_Int(CarFile(i), "paintjob");
    
Vehicles[i][carteam] = dini_Int(CarFile(i), "carteam");
    
Vehicles[i][cartype] = dini_Int(CarFile(i), "cartype");
    
Vehicles[i][modeltype] = dini_Int(CarFile(i), "modeltype");
    
Vehicles[i][biznumber] = dini_Int(CarFile(i), "biznumber");
    
Vehicles[i][reset] = dini_Int(CarFile(i), "resetted");
    
Vehicles[i][vw] = dini_Int(CarFile(i), "vw");
    
Vehicles[i][carprice] = dini_Int(CarFile(i), "price");
    
myStrcpy(Vehicles[i][jobname], dini_Get(CarFile(i), "jobname"));
    
myStrcpy(Vehicles[i][carowner],dini_Get(CarFile(i), "owner"));
    
myStrcpy(Vehicles[i][dupekey],dini_Get(CarFile(i), "dupekey"));
    
myStrcpy(Vehicles[i][numberplate],dini_Get(CarFile(i),"numberplate"));
    
sscanf(dini_Get(CarFile(i), "components"), "p<,>iiiiiiiiiiiiii",
    
Vehicles[i][Components][0],
    
Vehicles[i][Components][1],
    
Vehicles[i][Components][2],
    
Vehicles[i][Components][3],
    
Vehicles[i][Components][4],
    
Vehicles[i][Components][5],
    
Vehicles[i][Components][6],
    
Vehicles[i][Components][7],
    
Vehicles[i][Components][8],
    
Vehicles[i][Components][9],
    
Vehicles[i][Components][10],
    
Vehicles[i][Components][11],
    
Vehicles[i][Components][12],
    
Vehicles[i][Components][13]);
    
SetTimerEx("ModCar"20000"d"i);
    if(
Vehicles[i][carprice] == -1)
    {
        
dini_IntSet(CarFile(i), "price"0);
        
Vehicles[i][carprice] = 0;
    }
    new 
__a CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    
SetVehicleVirtualWorld(__aVehicles[i][vw]);
    if(
Vehicles[i][carprice]) UnlockVehicle(i);
    
format(iStrsizeof(iStr), "{d30404}LS - {000000}%d"i);
    
SetVehicleNumberPlate(iiStr);
    
SetVehicleToRespawn(i);
}
//When you buy a car:
dini_FloatSet(CarFile(carid), "x"1859.228637);
dini_FloatSet(CarFile(carid), "y", -1849.452026);
dini_FloatSet(CarFile(carid), "z"13.579807);
dini_FloatSet(CarFile(carid), "a"8.9621);
dini_IntSet(CarFile(carid), "resetted"0);
dini_IntSet(CarFile(carid), "cartype"0);
dini_IntSet(CarFile(carid), "carteam"0);
dini_IntSet(CarFile(carid), "model"jobcars[listitem][jcmodel]);
dini_Set(CarFile(carid), "owner"PlayerName(playerid));
new 
plate[12];
format(plate,sizeof(plate),"{d30404}LS - {000000}%d",carid);
dini_Set(CarFile(carid),"numberplate",plate);
ReloadVehicle(carid);
//The command (in OnPlayerCommandText; you can change the command processor):
if(!strcmp(cmdtext,"/cnplate",true))
{
    new 
plate[12];
    if(
sscanf(cmdtext,"s[12]",plate))return SendClientMessage(playerid,-1,"/cnplate [number plate]");
    
//Here you can go on

You have to go on with the command. You have to check if the player is in a vehicle and so on. Also you have to set the number plate of the vehicle (maybe you have to check if the player is the owner of this car).
Thanks!
Just a little quick thing, can you make the default (so nothing is set) to the car id?


Re: Dynamic car system help - Mencent - 29.03.2016

What do you mean. Would you like to have a command which set the values to default?