[MAX_PLAYERS] must be indexed
#1

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

externalplayerid[playerid] = clickedplayerid;

playerid - is the player that click on the other player's name in TAB.
Reply
#3

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

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

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
Код:
JailTime(playerid);
and this will cause problem because the cop will be jailed not the suspect.
Reply
#6

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

thank you i will try this and come back with result
Reply
#8

Ok.Just tell me if it worked.
Reply
#9

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;
Reply
#10

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]);
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)