13.01.2012, 11:41
Is there anyway to define playerid in this function so i can use
pawn Код:
new id;
id = GetPlayerVehicleID(playerid);
new id;
id = GetPlayerVehicleID(playerid);
new id, playerid = 12; //<--- or the ID you wish to use other than 12..
id = GetPlayerVehicleID(playerid);
stock GetVehicleDriver(vehicleid)
{
foreach(Player,i)//replace with usual for(.. if you dont use foreach
{
if (IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2)
{
return i;
}
}
return -1;
}
pawn Код:
OnVehicleDeath already gives you the vehicle id.. OnVehicleDeath(vehicleid /* <--this one */, killerid) |
public OnVehicleDeath(vehicleid, killerid)
{
new i;//New i which defines our playerid..
for(i = 0; i < MAX_PLAYERS; i ++)// i = 0 and is less than MAX_PLAYERS, increase 0 and loop untill you get to MAX_PLAYERS and return 1..
{
if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid)//If the player id is connected and there vehicle id = the vehicleid that was destroyed..
{
DestroyObject(VehicleBomb[vehicleid][0]);
DestroyObject(VehicleBomb[vehicleid][1]);
VehicleFire[vehicleid] = 0;
}
}
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
DestroyObject(VehicleBomb[vehicleid][0]);
DestroyObject(VehicleBomb[vehicleid][1]);
VehicleFire[vehicleid] = 0;
return 1;
}
Then I dont get your need, why you need player involve in vehicle functions, just use:
pawn Код:
|
COMMAND:unload(playerid,vehicleid, params[])
{
new id;
id = GetPlayerVehicleID(playerid);
DestroyObject(VehicleBomb[id][0]);
DestroyObject(VehicleBomb[id][1]);
VehicleFire[id] = 1;
return 1;
}