How to get playerid under such callback as OnVehicleSpawn - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to get playerid under such callback as OnVehicleSpawn (
/showthread.php?tid=273355)
How to get playerid under such callback as OnVehicleSpawn -
[WSF]ThA_Devil - 01.08.2011
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
Re: How to get playerid under such callback as OnVehicleSpawn -
Tigerkiller - 01.08.2011
pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++;)
with a loop you can make it
Re: How to get playerid under such callback as OnVehicleSpawn -
[WSF]ThA_Devil - 01.08.2011
ty, i hope it will work
Re: How to get playerid under such callback as OnVehicleSpawn -
[WSF]ThA_Devil - 01.08.2011
Код:
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++;)
Re: How to get playerid under such callback as OnVehicleSpawn -
alpha500delta - 01.08.2011
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++)
Re: How to get playerid under such callback as OnVehicleSpawn -
[WSF]ThA_Devil - 01.08.2011
thanks, i hope it works in game... script is k
Re: How to get playerid under such callback as OnVehicleSpawn -
Kitten - 01.08.2011
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;
}
Re: How to get playerid under such callback as OnVehicleSpawn -
AndreT - 01.08.2011
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.