Vehicle spawn command
#1

I have this vehicle spawning command, but there is a problem with it ;/ When a spawned vehicle is destroyed it respawns and i dont want them to respawn when they are spawned using this command.

Код:
if(!strcmp(cmdtext, "/scar", false, 5))
{
    if(!strlen(cmdtext[5]) return SendClientMessage(playerid, red, "Usage: /scar [Model ID]");
    new veh = strval(cmdtext[5]);
    if(veh < 400 || veh > 611) return SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
    CreateVehicle(veh, x,y,z, a, -1, -1, -1);
    return 1;
}
Reply
#2

You could always do this

pawn Код:
new sCar[MAX_PLAYERS];
pawn Код:
if(!strcmp(cmdtext, "/scar", false, 5))
{
    if(!strlen(cmdtext[5]) return SendClientMessage(playerid, red, "Usage: /scar [Model ID]");
    new veh = strval(cmdtext[5]);
    if(veh < 400 || veh > 611) return SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
    sCar[playerid] = CreateVehicle(veh, x,y,z, a, -1, -1, -1);
    return 1;
}
pawn Код:
public OnVehicleDeath(vehicleid)
{
    for(new x; x<MAX_PLAYERS; x++)
    {
        if(sCar[x] != 0) continue;
        if(sCar[x] == vehicleid)
        {
            DestroyVehicle(vehicleid);
            break;
        }
    }
    return 1;
}
Reply
#3

I would prefer the first offer Okay i will try it out.
Reply
#4

Is it possible to do it without [playerid] in this line
Код:
sCar[playerid]
because it causes some problems ;/
Reply
#5

What line is the error on? There was a missing equals sign on OnVehicleDeath.
Reply
#6

Yes i see but is it possible to use just sCar instead of sCar[playerid] ? Because [playerid] causes some problems :/
Reply
#7

Unless you are going to have one player on the server constantly, no. What I have done is made it so there is one vehicle ID per player.
Reply
#8

Well i got another idea. OnPlayerDeath i get the vehicle model and if that model is from the car market it is destroyed. /scar command was like a comparison.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)