Removing the vehicles a player spawned when they die.
#6

I'm on a tablet ATM but I'll try.
EDIT: finally.
pawn Код:
#define MAX_PVEH (10) // max vehicles a player can spawn
new
    gPlayerVeh[MAX_PLAYERS][MAX_PVEH],
    gVehsSpawned[MAX_PLAYERS]
;

// in create cmd:
new idx = gVehsSpawned[playerid];
if (idx >= MAX_PVEH) return SCM(playerid, -1, "Can't create any more vehicles - max reached! (10)");
// but beware: if you do not plan on deleting every vehicle this 'idx' stuff won't work
// as planned - you would have to write a 'GetFreeSlot" function..
gPlayerVeh[playerid][idx] = CreateVehicle(...);
gVehsSpawned[playerid]++;

// under OnPlayerDeath:
for (new i; i < MAX_PVEH; i++)
{
    if (IsValidVehicle(gPlayerVeh[playerid][i]))
    {
        DestroyVehicle(gPlayerVeh[playerid][i]);
        gPlayerVeh[playerid][i] = INVALID_VEHICLE_ID;
        gVehsSpawned[playerid]--;
    }
}
I apologise for any indentation mistakes!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)