Spawning Multiple Vehicles But Only Need One
#1

Whole script is not given.
When I go onto my server four vehicles are created where the one vehicle should be.

Enumeration
PHP Code:
enum VehicleInfo {
    
Owner,
    
OwnerType,
    
Model,
    
Float:PosX,
    
Float:PosY,
    
Float:PosZ,
    
Float:PosA,
    
Color1,
    
Color2,
    
Mod0,
    
Mod1,
    
Mod2,
    
Mod3,
    
Mod4,
    
Mod5,
    
Mod6,
    
Mod7,
    
Mod8,
    
Mod9,
    
Mod10,
    
Mod11,
    
Mod12,
    
Mod13,
    
Paintjob,
    
ID
}
new 
vInfo[5000][VehicleInfo]; 
Forwards
PHP Code:
forward LoadVehicle(vehicleid);
forward SaveVehicle(vehicleid);
forward SaveVehicles(); 
OnGameModInit Callback
PHP Code:
public OnGameModeInit()
{
    
// ^^^ Other Crap ^^^ //
    
SetTimer("SaveVehicles"60000true);
    
    
LoadVehicle(0);
    
    return 
1;

Load Vehicle Public
PHP Code:
public LoadVehicle(vehicleid)
{
    new 
file[256];
    
format(file256"Vehicles/%i.ini"vehicleid);
    
format(vInfo[vehicleid][Owner], 256"%s"dini_Get(file"Owner"));
    
vInfo[vehicleid][OwnerType] = dini_Int(file"OwnerType");
    
vInfo[vehicleid][Model] = dini_Int(file"Model");
    
vInfo[vehicleid][PosX] = dini_Float(file"PosX");
    
vInfo[vehicleid][PosY] = dini_Float(file"PosY");
    
vInfo[vehicleid][PosZ] = dini_Float(file"PosZ");
    
vInfo[vehicleid][PosA] = dini_Float(file"PosA");
    
vInfo[vehicleid][Color1] = dini_Int(file"Color1");
    
vInfo[vehicleid][Color2] = dini_Int(file"Color2");
    
vInfo[vehicleid][Mod0] = dini_Int(file"Mod0");
    
vInfo[vehicleid][Mod1] = dini_Int(file"Mod1");
    
vInfo[vehicleid][Mod2] = dini_Int(file"Mod2");
    
vInfo[vehicleid][Mod3] = dini_Int(file"Mod3");
    
vInfo[vehicleid][Mod4] = dini_Int(file"Mod4");
    
vInfo[vehicleid][Mod5] = dini_Int(file"Mod5");
    
vInfo[vehicleid][Mod6] = dini_Int(file"Mod6");
    
vInfo[vehicleid][Mod7] = dini_Int(file"Mod7");
    
vInfo[vehicleid][Mod8] = dini_Int(file"Mod8");
    
vInfo[vehicleid][Mod9] = dini_Int(file"Mod9");
    
vInfo[vehicleid][Mod10] = dini_Int(file"Mod10");
    
vInfo[vehicleid][Mod11] = dini_Int(file"Mod11");
    
vInfo[vehicleid][Mod12] = dini_Int(file"Mod12");
    
vInfo[vehicleid][Mod13] = dini_Int(file"Mod13");
    
vInfo[vehicleid][Paintjob] = dini_Int(file"Paintjob");
    
vInfo[vehicleid][ID] = CreateVehicle(vInfo[vehicleid][Model], vInfo[vehicleid][PosX], vInfo[vehicleid][PosY], vInfo[vehicleid][PosZ], vInfo[vehicleid][PosA], vInfo[vehicleid][Color1], vInfo[vehicleid][Color2], -1);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod0]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod1]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod2]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod3]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod4]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod5]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod6]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod7]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod8]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod9]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod10]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod11]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod12]);
    
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod13]);
    
ChangeVehiclePaintjob(vInfo[vehicleid][ID], vInfo[vehicleid][Paintjob]);
    return 
1;

Save Vehicle Public
PHP Code:
public SaveVehicle(vehicleid)
{
    new 
file[256];
    
format(file256"Vehicles/%i.ini"vehicleid);
    if(!
dini_Exists(file))
    {
        
dini_Create(file);
    }
    
dini_Set(file"Owner"vInfo[vehicleid][Owner]);
    
dini_IntSet(file"OwnerType"vInfo[vehicleid][OwnerType]);
    
dini_IntSet(file"Model"vInfo[vehicleid][Model]);
    
dini_FloatSet(file"PosX"vInfo[vehicleid][PosX]);
    
dini_FloatSet(file"PosY"vInfo[vehicleid][PosY]);
    
dini_FloatSet(file"PosZ"vInfo[vehicleid][PosZ]);
    
dini_FloatSet(file"PosA"vInfo[vehicleid][PosA]);
    
dini_IntSet(file"Color1"vInfo[vehicleid][Color1]);
    
dini_IntSet(file"Color2"vInfo[vehicleid][Color2]);
    
dini_IntSet(file"Mod0"vInfo[vehicleid][Mod0]);
    
dini_IntSet(file"Mod1"vInfo[vehicleid][Mod1]);
    
dini_IntSet(file"Mod2"vInfo[vehicleid][Mod2]);
    
dini_IntSet(file"Mod3"vInfo[vehicleid][Mod3]);
    
dini_IntSet(file"Mod4"vInfo[vehicleid][Mod4]);
    
dini_IntSet(file"Mod5"vInfo[vehicleid][Mod5]);
    
dini_IntSet(file"Mod6"vInfo[vehicleid][Mod6]);
    
dini_IntSet(file"Mod7"vInfo[vehicleid][Mod7]);
    
dini_IntSet(file"Mod8"vInfo[vehicleid][Mod8]);
    
dini_IntSet(file"Mod9"vInfo[vehicleid][Mod9]);
    
dini_IntSet(file"Mod10"vInfo[vehicleid][Mod10]);
    
dini_IntSet(file"Mod11"vInfo[vehicleid][Mod11]);
    
dini_IntSet(file"Mod12"vInfo[vehicleid][Mod12]);
    
dini_IntSet(file"Mod13"vInfo[vehicleid][Mod13]);
    
dini_IntSet(file"Paintjob"vInfo[vehicleid][Paintjob]);
    return 
1;

Save Vehicles Public
PHP Code:
public SaveVehicles()
{
    for(new 
vehicleid 0vehicleid 5000vehicleid++)
    {
        if(
vInfo[vehicleid][Model])
        {
            new 
file[256];
            
format(file256"Vehicles/%i.ini"vehicleid);
            if(!
dini_Exists(file))
            {
                
dini_Create(file);
            }
            
dini_Set(file"Owner"vInfo[vehicleid][Owner]);
            
dini_IntSet(file"OwnerType"vInfo[vehicleid][OwnerType]);
            
dini_IntSet(file"Model"vInfo[vehicleid][Model]);
            
dini_FloatSet(file"PosX"vInfo[vehicleid][PosX]);
            
dini_FloatSet(file"PosY"vInfo[vehicleid][PosY]);
            
dini_FloatSet(file"PosZ"vInfo[vehicleid][PosZ]);
            
dini_FloatSet(file"PosA"vInfo[vehicleid][PosA]);
            
dini_IntSet(file"Color1"vInfo[vehicleid][Color1]);
            
dini_IntSet(file"Color2"vInfo[vehicleid][Color2]);
            
dini_IntSet(file"Mod0"vInfo[vehicleid][Mod0]);
            
dini_IntSet(file"Mod1"vInfo[vehicleid][Mod1]);
            
dini_IntSet(file"Mod2"vInfo[vehicleid][Mod2]);
            
dini_IntSet(file"Mod3"vInfo[vehicleid][Mod3]);
            
dini_IntSet(file"Mod4"vInfo[vehicleid][Mod4]);
            
dini_IntSet(file"Mod5"vInfo[vehicleid][Mod5]);
            
dini_IntSet(file"Mod6"vInfo[vehicleid][Mod6]);
            
dini_IntSet(file"Mod7"vInfo[vehicleid][Mod7]);
            
dini_IntSet(file"Mod8"vInfo[vehicleid][Mod8]);
            
dini_IntSet(file"Mod9"vInfo[vehicleid][Mod9]);
            
dini_IntSet(file"Mod10"vInfo[vehicleid][Mod10]);
            
dini_IntSet(file"Mod11"vInfo[vehicleid][Mod11]);
            
dini_IntSet(file"Mod12"vInfo[vehicleid][Mod12]);
            
dini_IntSet(file"Mod13"vInfo[vehicleid][Mod13]);
            
dini_IntSet(file"Paintjob"vInfo[vehicleid][Paintjob]);
        }
    }
    return 
1;

/setvehicle command used to create vehicle file.
PHP Code:
dcmd_setvehicle(playeridparams[])
{
    if(
pInfo[playerid][Rank] >= 3)
    {
        new 
owner[256], ownertypecolor1color2;
        if(
sscanf(params"siii"ownerownertypecolor1color2))
        {
            
SendClientMessage(playeridCOLOR_PINK"   Usage: /setvehicle [owner] [ownertype] [color1] [color2]");
            
SendClientMessage(playeridCOLOR_PINK"      [Owners] Factions: 1(Police) 2(EMS)");
            
SendClientMessage(playeridCOLOR_PINK"      [Owner Types] 1(Player) 2(Faction) 3(Public)");
        }
        else if(
ownertype || ownertype 3)
        {
            
SendClientMessage(playeridCOLOR_ORANGE"   Invalid Owner Type");
        }
        else if(
color1 || color1 256)
        {
            
SendClientMessage(playeridCOLOR_ORANGE"   Invalid Color1");
        }
        else if(
color2 || color2 256)
        {
            
SendClientMessage(playeridCOLOR_ORANGE"   Invalid Color2");
        }
        else
        {
            for(new 
vehicleid 0vehicleid 5000vehicleid++)
            {
                if(
vInfo[vehicleid][Model] == 0)
                {
                    
format(vInfo[vehicleid][Owner], 256"%s"owner);
                    
vInfo[vehicleid][OwnerType] = ownertype;
                    
vInfo[vehicleid][Model] = GetVehicleModel(GetPlayerVehicleID(playerid));
                    new 
Float:xFloat:yFloat:zFloat:a;
                    
GetVehiclePos(GetPlayerVehicleID(playerid), xyz);
                    
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
                    
vInfo[vehicleid][PosX] = x;
                    
vInfo[vehicleid][PosY] = y;
                    
vInfo[vehicleid][PosZ] = z;
                    
vInfo[vehicleid][PosA] = a;
                    
vInfo[vehicleid][Color1] = color1;
                    
vInfo[vehicleid][Color2] = color2;
                    new 
output[256];
                    
format(output256"   Vehicle File(%i) Created"vehicleid);
                    return 
SendClientMessage(playeridCOLOR_WHITEoutput);
                }
            }
            
SendClientMessage(playeridCOLOR_ORANGE"   Vehicle Limit Reached");
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"   Commmand Doesn't Exists");
    }
    return 
1;

Vehicles/0.ini File - "Owner" should equal nobody no reason why.
PHP Code:
Owner=Nљ’nKЊ
OwnerType
=3
Model
=410
PosX
=1291.799072
PosY
=343.792419
PosZ
=19.206686
PosA
=65.997161
Color1
=3
Color2
=3
Mod0
=0
Mod1
=0
Mod2
=0
Mod3
=0
Mod4
=0
Mod5
=0
Mod6
=0
Mod7
=0
Mod8
=0
Mod9
=0
Mod10
=0
Mod11
=0
Mod12
=0
Mod13
=0
Paintjob
=
This is from my custom script. Please do not steal. Only posted for debugging purposes.
Reply


Messages In This Thread
Spawning Multiple Vehicles But Only Need One - by AustinJ74 - 02.06.2011, 02:10
Re: Spawning Multiple Vehicles But Only Need One - by Backwardsman97 - 02.06.2011, 04:28
Re: Spawning Multiple Vehicles But Only Need One - by Mike Garber - 02.06.2011, 08:30

Forum Jump:


Users browsing this thread: 1 Guest(s)