public OnVehicleDeath(vehicleid, killerid) -
cruising - 13.01.2012
Is there anyway to define playerid in this function so i can use
pawn Код:
new id;
id = GetPlayerVehicleID(playerid);
Re: public OnVehicleDeath(vehicleid, killerid) -
iPLEOMAX - 13.01.2012
pawn Код:
new id, playerid = 12; //<--- or the ID you wish to use other than 12..
id = GetPlayerVehicleID(playerid);
But why do you wanna use that?
OnVehicleDeath already gives you the vehicle id..
OnVehicleDeath(vehicleid /* <--this one */, killerid)
Re: public OnVehicleDeath(vehicleid, killerid) -
Voldemort - 13.01.2012
pawn Код:
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;
}
Re: public OnVehicleDeath(vehicleid, killerid) -
iPLEOMAX - 13.01.2012
Ah
Voldemort, you got him right..
@
cruising, you needed to find the driver's ID?
Re: public OnVehicleDeath(vehicleid, killerid) -
cruising - 13.01.2012
Quote:
Originally Posted by iPLEOMAX
pawn Код:
new id, playerid = 12; //<--- or the ID you wish to use other than 12.. id = GetPlayerVehicleID(playerid);
But why do you wanna use that?
OnVehicleDeath already gives you the vehicle id..
OnVehicleDeath(vehicleid /* <--this one */, killerid)
|
I wanna use that so i can make this code get the playerids vehicleid to remove these objects, or else it removes the objects for all players if i use "vehicleid" instead of "id"
pawn Код:
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;
}
Re: public OnVehicleDeath(vehicleid, killerid) -
cruising - 13.01.2012
Quote:
Originally Posted by Voldemort
pawn Код:
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; }
|
Im not sure about this code, i need to check the playerids vehicle id, and this code doesnt do that, or are im wrong?
Re: public OnVehicleDeath(vehicleid, killerid) -
Voldemort - 13.01.2012
Then I dont get your need, why you need player involve in vehicle functions, just use:
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
DestroyObject(VehicleBomb[vehicleid][0]);
DestroyObject(VehicleBomb[vehicleid][1]);
VehicleFire[vehicleid] = 0;
return 1;
}
Because there is only 1
VehicleBomb[vehicleid][0]); object, dont need to make a loop for players
Re: public OnVehicleDeath(vehicleid, killerid) -
cruising - 13.01.2012
Quote:
Originally Posted by Voldemort
Then I dont get your need, why you need player involve in vehicle functions, just use:
pawn Код:
public OnVehicleDeath(vehicleid, killerid) { DestroyObject(VehicleBomb[vehicleid][0]); DestroyObject(VehicleBomb[vehicleid][1]); VehicleFire[vehicleid] = 0; return 1; }
Because there is only 1 VehicleBomb[vehicleid][0]); object, dont need to make a loop for players
|
The thing is if you use the /load cmd and get ur bombs, and you crash ur vehicle, its also removes the bombs for all other players and not only on your own vehicle you was using.
And same on this code..if you exit, you remove all other players bombs to
pawn Код:
COMMAND:unload(playerid,vehicleid, params[])
{
new id;
id = GetPlayerVehicleID(playerid);
DestroyObject(VehicleBomb[id][0]);
DestroyObject(VehicleBomb[id][1]);
VehicleFire[id] = 1;
return 1;
}