[MAX_PLAYERS] must be indexed -
NvidiaForTheWin - 09.06.2013
hi all
i have another problem.
i need to get the clickedplayerid on OnPlayerClickPlayer to use it later outside of OnPlayerClickPlayer.
so this is what i do
on top of code
Код:
new externalplayerid;
on OnPlayerClickPlayer
Код:
externalplayerid = clickedplayerid;
it work but can only be used once. ( if 2 player use it at same time , only the last one is stored )
i tried this
Код:
new externalplayerid[MAX_PLAYERS];
and
Код:
externalplayerid[WHAT I PUT HERE] = clickedplayerid;
but the problem here is that i cant use [playerid] as they are not in my custom function and give error.
and i think it will create lots of id mix up problem.
i tried
Код:
externalplayerid[externalplayerid] = clickedplayerid;
it say array must be indexed right there and everywhere i need to use it.
any idea ?
Re: [MAX_PLAYERS] must be indexed -
Aly - 09.06.2013
externalplayerid[playerid] = clickedplayerid;
playerid - is the player that click on the other player's name in TAB.
Re : [MAX_PLAYERS] must be indexed -
NvidiaForTheWin - 09.06.2013
thanks but i know
Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
if i only use
Код:
new externalplayerid;
then if 3 players click on a player on tab at same time, only the last one will be stored.
this is the problem.
hope you understand and can help me
Re: [MAX_PLAYERS] must be indexed -
Aly - 09.06.2013
OK.Just put this on the top of the script:
pawn Код:
new externalplayerid[MAX_PLAYERS];
Add this under OnPlayerConnect:
pawn Код:
OnPlayerConnect(playerid)
{
externalplayerid[playerid] = 999;
}
Add this to OnPlayerClickPlayer:
pawn Код:
OnPlayerClickPlayer(playerid,clickedplayerid,source)
{
externalplayerid[playerid] = clickedplayerid;
}
Re : [MAX_PLAYERS] must be indexed -
NvidiaForTheWin - 09.06.2013
ok i will try.
but what about my custom function ?
ex:
Код:
forward JailTime();
public JailTime()
{
SetPlayerPos(externalplayerid, 1553.7046,-1675.6191,16.1953);
SetPlayerFacingAngle(externalplayerid, 89.9057);
}
i cannot do it like
Код:
public JailTime(playerid)
because i will have to call the function with playerid
and this will cause problem because the cop will be jailed not the suspect.
Re: [MAX_PLAYERS] must be indexed -
Aly - 09.06.2013
Then you will put:
pawn Код:
forward JailTime(playerid);
public JailTime(playerid)
{
SetPlayerPos(playerid, 1553.7046,-1675.6191,16.1953);
SetPlayerFacingAngle(playerid, 89.9057);
}
And now when you will call the function: JailTime , you will call it like this:
pawn Код:
JailTime(externalplayerid[playerid]);
This one will put the player that you clicked into those coords.
I guess that's what you wanted to do ,right?
Re : [MAX_PLAYERS] must be indexed -
NvidiaForTheWin - 09.06.2013
thank you i will try this and come back with result
Re: [MAX_PLAYERS] must be indexed -
Aly - 09.06.2013
Ok.Just tell me if it worked.
Re : [MAX_PLAYERS] must be indexed -
NvidiaForTheWin - 09.06.2013
it seem to work now.
i cannot test with multiple player as im trying with my desktop and laptop for now ( my friend isnt online ).
now i have these error
Код:
C:\Users\nvidia\Desktop\RPG\gamemodes\MyVirtualLife.pwn(3141) : error 012: invalid function call, not a valid address
C:\Users\nvidia\Desktop\RPG\gamemodes\MyVirtualLife.pwn(3141) : warning 215: expression has no effect
C:\Users\nvidia\Desktop\RPG\gamemodes\MyVirtualLife.pwn(3141) : error 001: expected token: ";", but found ")"
C:\Users\nvidia\Desktop\RPG\gamemodes\MyVirtualLife.pwn(3141) : error 029: invalid expression, assumed zero
C:\Users\nvidia\Desktop\RPG\gamemodes\MyVirtualLife.pwn(3141) : fatal error 107: too many error messages on one line
here the line
Код:
forward Suspecter(playerid);
public Suspecter(playerid)
{
IsPlayerSuspected(externalplayerid[playerid]) = 1;
}
i also tried
Код:
IsPlayerSuspected[externalplayerid[playerid]] = 1;
Re: [MAX_PLAYERS] must be indexed -
Aly - 09.06.2013
It should look like this:
On the top:
pawn Код:
new IsPlayerSuspected[MAX_PLAYERS];
pawn Код:
forward Suspecter(playerid);
public Suspecter(playerid)
{
IsPlayerSuspected[playerid] = 1;
}
And when you call the function , I mean when you suspect him , when you click on him like this:
pawn Код:
Suspecter(externalplayerid[playerid]);