Stupid vehicle system[Please Help Me]
#1

Hey there !

Im trying to make a vehicle system for my GM

Everything I done :

Forwards

pawn Код:
forward GetVehicleSlot();
forward VehicleCreate(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[21]);
forward SaveVehicleData(vehicle,fName[37]);
forward LoadVehicleData(fName[37]);
forward LoadAllVehiclesData();
Publics

pawn Код:
public GetVehicleSlot()
{
    for(new v = 0; v < sizeof(valid); v++)
    {
        if(!valid[v]) return v;
    }
    return -1;
}

public VehicleCreate(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[21])
{
    new id = GetVehicleSlot();
    CarData[id][model] = modelid;
    CarData[id][posX] = x;
    CarData[id][posY] = y;
    CarData[id][posZ] = z;
    CarData[id][fAngle] = angle;
    CarData[id][cColor1] = color1;
    CarData[id][cColor2] = color2;
    CarData[id][respawn] = respawntime;
    CarData[id][owner] = ownername;
    valid[id] = true;
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
    return id;
}

public SaveVehicleData(vehicle,fName[37])
{
    if(!dini_Exists(fName))
    {
        dini_Create(fName);
    }
    dini_IntSet(fName,"Model",CarData[vehicle][model]);
    dini_FloatSet(fName,"PosX",CarData[vehicle][posX]);
    dini_FloatSet(fName,"PosY",CarData[vehicle][posY]);
    dini_FloatSet(fName,"PosZ",CarData[vehicle][posZ]);
    dini_FloatSet(fName,"Angle",CarData[vehicle][fAngle]);
    dini_IntSet(fName,"Color1",CarData[vehicle][cColor1]);
    dini_IntSet(fName,"Color2",CarData[vehicle][cColor2]);
    dini_IntSet(fName,"RespawnTime",CarData[vehicle][respawn]);
    dini_Set(fName,"Owner",CarData[vehicle][owner]);
}

public LoadVehicleData(fName[37])
{
    CreateVehicle(dini_Int(fName,"Model"),dini_Float(fName,"PosX"),dini_Float(fName,"PosY"),dini_Float(fName,"PosZ"),dini_Float(fName,"Angle"),dini_Int(fName,"Color1"),dini_Int(fName,"Color2"),dini_Int(fName,"RespawnTime"));
}

public LoadAllVehiclesData()
{
    new vName[37],index = 0;
    format(vName,sizeof(vName),"%d.ini",index);
    while(dini_Exists(vName))
    {
        LoadVehicleData(vName);
        index++;
        format(vName, sizeof(vName), "%d.ini", index);
    }
}
Under OnGameModeInIt
pawn Код:
LoadAllVehiclesData();

Now for the problems

How can I load the vehicle's owner ?
strmid ? if yes ? then how to ?

Second problem and the worst one ..
I tried to make a command (for testing) that will create a vehicle near me ...
Like this

pawn Код:
if(strcmp(cmd,"/lcar",true) == 0)
    {
            new tmp[256];
            tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return 1;
        new Float:X,Float:Y,Float:Z;
        GetPlayerPos(playerid,X,Y,Z);
        new str[256];
        format(str,sizeof(str),"%s",GetName(playerid));
            VehicleCreate(strval(tmp),X,Y+2.0,Z,360,10,10,-1,str);
       
    }
It gave me this error

Код:
error 047: array sizes do not match, or destination array is too small
line

Код:
VehicleCreate(strval(tmp),X,Y+2.0,Z,360,10,10,-1,str);












Reply
#2

pawn Код:
new str[21];
Reply
#3

For the name you can do this:
pawn Код:
// Instead of this
CarData[id][owner] = ownername;  

// Put this
format(CarData[id][owner], MAX_PLAYER_NAME, "%s", ownername);
And that should fix the command.
Reply
#4

Thanks guys no errors no but ... It doesnt add the vehicle.
And I think it returns 0 (or maybe it not returns anything at all)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)