SA-MP Forums Archive
Vehicle System [+REP] - 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: Vehicle System [+REP] (/showthread.php?tid=333723)



Vehicle System [+REP] - Itzhak E. - 12.04.2012

Hey..
I never scripted a vehicle system, so now I'm now working on TDM mod.
I need to script vehicle system that there are Vehicles for Team 1 and Team 2.
By the way, I'm using Y_INI, zCmd, and sscanf.
Please help me with that, and if you could explain me how everything work, because I wan to know for the next times.
I tried to do the vehicle system from the tutorial that posted in the "Tutorials" forum and itsn't worked.
Thanks!


Re: Vehicle System [+REP] - Libra_PL - 12.04.2012

Well, I would need more information. Just place vehicles or make them openable only for one team?


Re: Vehicle System [+REP] - Itzhak E. - 12.04.2012

Hmm.. I need information on just open file with vehicle data, for ex: X,Y,Z,Angle,Model,Team,RespawnTime...
about openable only for one team it's when player enter vehicle, like:
pawn Код:
if(gTeam[playerid] == 1 && vData[vehicleid][Team] == 1)
{
// code
}



Re: Vehicle System [+REP] - park4bmx - 12.04.2012

i would show u a few coeds of a Veh OwnerShip System(This a few codes of mine)
My one saves vehicle components,colors,player numbers,locked,etc so i will not add that to compicate things !

Im using Y_INI for this!
pawn Код:
#define MAX_CARS     100

enum Car_Info
{
    Model,
    Price,
    Float:CarX,
    Float:CarY,
    Float:CarZ,
    Float:CarRot,
    Locked,
    ColorA,
    ColorB,
};

new VehicleInfo[MAX_CARS][Car_Info];


//Laoding the car (this is a perse!)
forward LoadCar(playerid, name[], value[]);
public LoadCar(playerid, name[], value[])
{
if(!strcmp(name,"Model"))SetPVarInt(playerid,"Model",strval(value));
if(!strcmp(name,"Price"))SetPVarInt(playerid,"Price",strval(value));
if(!strcmp(name,"X"))SetPVarFloat(playerid,"X",strval(value));
if(!strcmp(name,"Y"))SetPVarFloat(playerid,"Y",strval(value));
if(!strcmp(name,"Z"))SetPVarFloat(playerid,"Z",strval(value));
if(!strcmp(name,"Rot"))SetPVarFloat(playerid,"Rot",strval(value));
if(!strcmp(name,"Locked"))SetPVarInt(playerid,"Locked",strval(value));
if(!strcmp(name,"ColorA"))SetPVarInt(playerid,"ColorA",strval(value));
if(!strcmp(name,"ColorB"))SetPVarInt(playerid,"ColorB",strval(value));
}

forward OnPlayerConnect(playerid);
public OnPlayerConnect(playerid)
{
//you will ahve to show the "file" 's directory
if(fexist(file))
    {
        VehicleInfo[playerid][Model] = GetPVarInt(playerid, "Model");
        VehicleInfo[playerid][Price] = GetPVarInt(playerid, "Price");
        VehicleInfo[playerid][CarX] = GetPVarFloat(playerid, "X");
        VehicleInfo[playerid][CarY] = GetPVarFloat(playerid, "Y");
        VehicleInfo[playerid][CarZ] = GetPVarFloat(playerid, "Z");
        VehicleInfo[playerid][CarRot] = GetPVarFloat(playerid, "Rot");
        VehicleInfo[playerid][ColorA] = GetPVarInt(playerid, "ColorA");
        VehicleInfo[playerid][ColorB] = GetPVarInt(playerid, "ColorB");
    }

//my custume Stock for saving the vehicle
stock SaveVehicle(playerid,ModelID,Float:X,Float:Y,Float:Z,Float:R,CarLocked,VehColorA,VehColorB)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"%s.txt",name);//directory name.path
    if(fexist(file))
    {
        new INI:Acc = INI_Open(file);
        INI_WriteInt(Acc,"Model", ModelID);
        INI_WriteFloat(Acc,"X", X);
        INI_WriteFloat(Acc,"Y", Y);
        INI_WriteFloat(Acc,"Z", Z);
        INI_WriteFloat(Acc,"Rot", R);
        //INI_WriteInt(Acc,"Locked", CarLocked);
        INI_WriteInt(Acc,"VehColorA", VehColorA);
        INI_WriteInt(Acc,"VehColorB", VehColorB);
        //INI_WriteInt(Acc,"VehicleFuel", FuelPercent[Vehicle[playerid]]);
        INI_Close(Acc);
    }else return false;
    return 1;
}



Re: Vehicle System [+REP] - Itzhak E. - 13.04.2012

Ok... Thanks, and could you show me it with sscanf?, something more where I define "file" and what the definition will be.