Function
#1

I wanted to know how to use functions and CallLocalFunction CallRemoteFunction, can also be used in OnPlayerConnect and OnPlayerDisconnect?
Reply
#2

help me
Reply
#3

Quote:
Originally Posted by TheBluec0de
Посмотреть сообщение
help me
Have a bit of patience. Yes you'll be able to use Call(Remote/Local)Function on any public function.


The usage is pretty simple and is explained on the WIKI. The params are the public function's name, its parameters as specifiers (i for ints, s for string, f for floats, etc), and then the actual parameters to pass to the function.
Reply
#4

I could do an example with onplayerconnect and disconnect?
Reply
#5

Type in a GM I have seen such a thing....

Код:
public OnPlayerConnect(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_AddPlayer(playerid);
	}
	if(...)
	{
		return CallLocalFunction(2964, 3064, playerid);
	}
	return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_RemovePlayer(playerid);
	}
	if(....)
	{
		return CallLocalFunction(3072, 3184, playerid, reason);
	}
	return 1;
}
Reply
#6

Quote:
Originally Posted by TheBluec0de
Посмотреть сообщение
I could do an example with onplayerconnect and disconnect?
Im not sure why you want to call these callbacks like this, but what ever lol.


Код:
CallRemoteFunction("OnPlayerConnect", "i", playerid);
Reply
#7

example: so?

Код:
public OnPlayerConnect(playerid)
{
    CallRemoteFunction("OnPlayerConnect", "i", playerid);
	return 1;
}
Reply
#8

help ?
Reply
#9

I Have the same Question: Why do you want to Use the function this way?

It's Mighty-Ultra-Mega-Supa-Useless calling OnPlayerConnect using the function.

@Kyosaur: This Callback matches your signature.. x)
Reply
#10

Quote:
Originally Posted by TheBluec0de
Посмотреть сообщение
example: so?

Код:
public OnPlayerConnect(playerid)
{
    CallRemoteFunction("OnPlayerConnect", "i", playerid);
	return 1;
}
No, that will be a never ending loop lol.


When you said you wanted to know how to use these functions, did you mean you wanted to know what they do? I thought you were asking for help on their syntax .


CallRemoteFunction calls a public function inside any loaded script. Lets say you have a public function in a filterscript called "Test" that you wanted to call from your GM. You would use this function to call it, and possibly use the return value from said function.

CallLocalFunction does the same, except it only works for the script its used it.


These functions only work with publics, as when you declare something public its name becomes visible to the virtual machine. Since we're passing the functions name as the first param the VM has to actually KNOW the name- hence the public.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)