[HELP]Vehicle Spawn Command Problem
#1

The Problem:
In Game When I Type /vspawn I Get The Message "[SYSTEM]: /vspawn [Vehicle Model] [Color 1] [Color 2]"
But If I Continue With: Vehicle Model, Color 1, Color 2 I Get Unknow Command

The Code:
pawn Код:
if (strcmp("/vspawn", cmdtext, true, 10) == 0)
{
new idx;
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp))
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: /vspawn [Vehicle Model] [Color 1] [Color 2]");
return 1;
}
new VehicleModel;
VehicleModel = strval(tmp);

if(VehicleModel < 400 || VehicleModel > 611)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Model Can't Be Below 400 Or Above 611");
return 1;
}
tmp = strtok(cmdtext, idx);

if(!strlen(tmp))
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: /vspawn [Vehicle Model] [Color 1] [Color 2]");
return 1;
}

new VehicleColor1;
VehicleColor1 = strval(tmp);

if(VehicleColor1 < 0 || VehicleColor1 > 126)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Color Can't Be Below 0 Or Above 126");
return 1;
}
tmp = strtok(cmdtext, idx);

if(!strlen(tmp))
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: /vspawn [Vehicle Model] [Color 1] [Color 2]");
return 1;
}
new VehicleColor2;
VehicleColor2 = strval(tmp);

if(VehicleColor2 < 0 || VehicleColor2 > 126)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Color Can't Be Below 0 Or Above 126");
return 1;
}
new vehicleid, Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);

vehicleid = CreateVehicle(VehicleModel, X, Y, Z, A, VehicleColor1, VehicleColor2, 0);
SetVehicleZAngle(vehicleid, A);
PutPlayerInVehicle(playerid, vehicleid, 0);
SetCameraBehindPlayer(playerid);
return 1;
}
Advise Thanks
Reply
#2

Use Sscanf
Reply
#3

Use dcmd/zcmd with sscanf, alot easier and better.
Reply
#4

I Want This Way....
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)