public OnVehicleDeath(vehicleid, killerid)
#1

Is there anyway to define playerid in this function so i can use
pawn Код:
new id;
id = GetPlayerVehicleID(playerid);
Reply
#2

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)
Reply
#3

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;
}
Reply
#4

Ah Voldemort, you got him right..

@cruising, you needed to find the driver's ID?
Reply
#5

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;
}
Reply
#6

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?
Reply
#7

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
Reply
#8

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;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)