Command Scripting: /v
#6

Simple codes, but should do the trick.
Considering the enum. of the player data is the "PlayerInfo" as the common used..

pawn Код:
// Anywhere, recommended to be after the variables, not in a function or a callback for sure.
enum pinfo
{
    Admin,
    SpawnedVehicle,
    HasVehicleSpawned,
}
new PlayerInfo[MAX_PLAYERS][pinfo];

// Same here, but recommended to be coded after the callbacks..
CMD:v(playerid, params[])
{
    new vehicleid, color1, color2, Float: x, Float: y, Float: z;
    if(sscanf(params,"iii", vehicleid, color1, color2)) return SendClientMessage(playerid, SOME_COLOR,"USAGE: /v [vehicleid] [color1] [color2]");
    GetPlayerPos(playerid, x, y, z);
    PlayerInfo[playerid][SpawnedVehicle] = CreateVehicle(vehicleid, x+2, y, z, 1.0, color1, color2, 1000);
    PlayerInfo[playerid][HasVehicleSpawned] = 1;
    return 1;
}

CMD:vdestroy(playerid, params[])
{
    if(!PlayerInfo[playerid][HasVehicleSpawned]) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You don't have a spawned vehicle to destroy.");
    DestroyVehicle(PlayerInfo[playerid][SpawnedVehicle]);
    PlayerInfo[playerid][HasVehicleSpawned] = 0;
    return 1;
}

CMD:respawnvehicles(playerid, params[])
{
    if(!PlayerInfo[playerid][Admin]) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You are not an administrator.");
    for(new v; v < MAX_VEHICLES; v++)
    {
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(!GetPlayerVehicleID(i) == v)
            {
                 SetVehicleToRespawn(v);
                 SendClientMessageToAll(SOME_COLOR,"Warning: All unused vehicles have been respawned by an administrator.");
                return 1;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Command Scripting: /v - by B-rian - 18.06.2012, 15:15
Re: Command Scripting: /v - by MarinacMrcina - 18.06.2012, 15:22
Re: Command Scripting: /v - by Avi57 - 18.06.2012, 15:22
Re: Command Scripting: /v - by B-rian - 18.06.2012, 15:25
Re: Command Scripting: /v - by A7X_CEEJAY - 18.06.2012, 15:35
Re: Command Scripting: /v - by Randy More - 18.06.2012, 15:41
Re: Command Scripting: /v - by B-rian - 18.06.2012, 19:04
Re: Command Scripting: /v - by A7X_CEEJAY - 18.06.2012, 19:38
Re: Command Scripting: /v - by B-rian - 18.06.2012, 20:32
Re: Command Scripting: /v - by B-rian - 18.06.2012, 20:34

Forum Jump:


Users browsing this thread: 1 Guest(s)