How to get playerid under such callback as OnVehicleSpawn
#1

Hello, i got problem with my cars owner ship system, to get car id i need to have playerid first, how to get it under OnVehicleSpawn
Reply
#2

pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++;)
with a loop you can make it
Reply
#3

ty, i hope it will work
Reply
#4

Код:
test.pwn(534) : error 001: expected token: ")", but found ";"
test.pwn(534) : error 036: empty statement
test.pwn(534) : error 029: invalid expression, assumed zero
test.pwn(534) : fatal error 107: too many error messages on one line
pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++;)
Reply
#5

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Код:
test.pwn(534) : error 001: expected token: ")", but found ";"
test.pwn(534) : error 036: empty statement
test.pwn(534) : error 029: invalid expression, assumed zero
test.pwn(534) : fatal error 107: too many error messages on one line
pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++;)
Well, firstly you can NOT use playerid in a loop, since it's already defined. This one is correct:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
Reply
#6

thanks, i hope it works in game... script is k
Reply
#7

example
pawn Код:
new Herro[MAX_PLAYERS];

public OnVehicleSpawn(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++) {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(i,Float:x,Float:y,Float:z);
        Herro[i] = CreateVehicle(411,Float:x,Float:y,Float:z,100.0,1,1,15);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Well, firstly you can NOT use playerid in a loop, since it's already defined. This one is correct:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
Well, firstly playerid is NOT defined in a callback which doesn't contain playerid in its header.

Here's an example of how to get the vehicle's driver when it is destroyed.
pawn Код:
public OnVehicleDeath(vehicleid)
{
    new playerid;
    for(playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerInVehicle(playerid, vehicleid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            break;
    }
    SendClientMessage(playerid, 0xFFFFFFFF, "What did you do to your vehicle?!");
    return true;
}
I wrote it from the top of my head but it should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)