20.05.2011, 12:09
Hey there !
Im trying to make a vehicle system for my GM
Everything I done :
Forwards
Publics
Under OnGameModeInIt
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
It gave me this error
line
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();
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);
}
}
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);
}
Код:
error 047: array sizes do not match, or destination array is too small
Код:
VehicleCreate(strval(tmp),X,Y+2.0,Z,360,10,10,-1,str);