View Full Version : Toggleplayercontrollable question?

28/05/2013, 09:15 PM
is there any function to detect if the player is freeze or not? coz i want to make a NOP check for toggleplayercontrollable.

28/05/2013, 09:22 PM
There is no such fuction but what you can do is this: As soon as you freeze them make a bool variable true or give to a simple variable the value 1. When unfreezing them make it false/0. Then you can make the check you want.

28/05/2013, 09:25 PM

28/05/2013, 09:54 PM
Pottus this is not what he asks for. He wants to see if a player is freezed or not. Very good ex function for saving health and armour data though.

28/05/2013, 10:10 PM
It has that function built in HL

#define IsPlayerFrozen(%0) PlayerIsFrozen[%0]

28/05/2013, 10:19 PM
Oh you are right.

For knowledge reason:
I can understand the "new bool:PlayerIsFrozen[MAX_PLAYERS];" but sincerely the line you posted above makes me feel stupid... Can you explain it?

28/05/2013, 10:29 PM
Basically when you compile the preprocessor will replace PlayerIsFrozen(playerid); with PlayerIsFrozen[playerid]; the playerid can actually be anything such as "i" if your doing a loop it's kinda like hiding the fact it is an array but using it as a function.

Here is another example from my sub-streamer include.

This creates a macro function define which is very useful.

#define OnCheckPoint:%1(%2,%3,%4) \
forward OnCP_%1(%2,%3,%4); \
public OnCP_%1(%2,%3,%4)

Now you can write in your script....

OnCheckPoint:MyCheckPoint(playerid, cpid, cpindex)

This is would be called through a CallLocalFunction()

CallLocalFunction(Fname, "iii", playerid, checkpointid, cpindex);

28/05/2013, 10:33 PM
Why not using PVars? Wherever you place TogglePlayerControllable function, use SetPVarInt to 1 and then make an if statement with GetPVarInt if you want to detect if the player is freezed. Remember to set your PVar to 0 when exit the server.

28/05/2013, 10:36 PM
PVars are bad practice and serve absolutely no purpose but to make ugly convoluted code.