if(!strcmp(cmdtext, "/pirmyn", true,17)) { DestroyVehicle(vehic[0]); vehic[1] = CreateVehicle(401,-1954.6177,260.2105,35.5101,33.9648,0,0,-1); return 1; } if(!strcmp(cmdtext, "/pirmyn2", true,17)) { DestroyVehicle(vehic[1]); vehic[2] = CreateVehicle(402,-1954.6177,260.2105,35.5101,33.9648,0,0,-1); return 1; }
new vehid; // at the top of the script
if(!strcmp(cmdtext, "/pirmyn", true,17))
{
DestroyVehicle(vehic[vehid]);
vehid++
vehic[vehid] = CreateVehicle(401,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
return 1;
}
pawn Code:
|
/* new vehid; // at top of the script if you are using it global */
if(!strcmp(cmdtext, "/pirmyn", true))
{
new vehid;
if(vehid >= 400 && vehid <= 611)
{
vehid = 400;
DestroyVehicle(vehic[vehid]);
vehid++;
vehic[vehid] = CreateVehicle(400,-1954.6177,260.2105,35.5101,33.9648,0,0,-1); // vehicles start with 400
}
else
{
vehid = 400;
}
return 1;
}
Added a few things
I've set the 'vehid' to 400 (model id starts with 400) Added a check to see if the model id is more than 400 and less than 611 (model id ends at 611) pawn Code:
|
#define LATEST_VEHID 3 // change this
new vehid = 0;
if(!strcmp(cmdtext, "/pirmyn", true))
{
DestroyVehicle(GetPlayerVehicleID(playerid));
vehid++;
if(vehid == 1)
{
CreateVehicle(400,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
}
else if(vehid == 2)
{
CreateVehicle(450,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
}
else if(vehid == 3)
{
CreateVehicle(511,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new keys, ud, lr;
GetPlayerKeys(playerid, keys, ud, lr);
if(lr > 0)
{
vehid++;
}
else if(lr < 0)
{
if(vehid <= 0)
{
vehid = LATEST_VEHID;
}
else
{
vehid--;
}
}
return 1;
}