How to create a new function -
saffierr - 23.08.2015
How do I create an new SetTimerEx function?
Currently I want this function to create "DelayedConnect"
AW: How to create a new function -
MrGtasagamer - 23.08.2015
Quote:
Originally Posted by saffierr
How do I create an new SetTimerEx function?
Currently I want this function to create "DelayedConnect"
|
Hey,
this should help!
https://sampwiki.blast.hk/wiki/Public_functions
AW: How to create a new function -
Kaliber - 23.08.2015
Can you please explain more...what you wanna do?
Re: How to create a new function -
Abagail - 23.08.2015
You are probably speaking about a callback which is called like a OnPlayerConnect callback but delayed, right? You can do something such as:
pawn Код:
new PlayerConnectTimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
PlayerConnectTimer[playerid] = SetTimerEx("DelayedConnect", 5000, false, "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason) return KillTimer(PlayerConnectTimer[playerid]);
forward DelayedConnect(playerid);
public DelayedConnect(playerid)
{
PlayerConnectTimer[playerid] = 0;
return 1;
}
Re: How to create a new function -
rymax99 - 23.08.2015
https://sampwiki.blast.hk/wiki/SetTimerEx
Код:
public OnPlayerConnect(playerid) {
SetTimerEx("DelayedFunction", 1000, false, "i", playerid); //calling function "DelayedFunction", AFTER 1000ms, nonrepeating, passing playerid to the function
return 1;
}
forward DelayedFunction(playerid);
public DelayedFunction(playerid) {
SendClientMessage(playerid, -1, "This message will be delayed 1 second after "OnPlayerConnect" is called.");
}
Re: How to create a new function -
saffierr - 23.08.2015
mmmm @MrGtaSagamer, your link has explained me a bit, although I do not understand it fully.
I have understood a part though(but thanks for the link, it's useful)
ALTHOUGH, mrgatsagamer could you explain me exactly, step by step how I create them? Would be very very appreciated.
Re: How to create a new function -
saffierr - 23.08.2015
Sorry for double post, but I will explain it.
PHP код:
public OnPlayerConnect(playerid)
{
new string[350], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string,sizeof string, "%s has joined the server.", pName);
SetTimerEx("DelayedConnect", 2000, false, "i", playerid);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
forward DelayedConnect(playerid);
public DelayedConnect(playerid);
When I connect to my server, it says "(Name) has joined the server.", I want to have my name at the very least
AW: Re: How to create a new function -
MrGtasagamer - 23.08.2015
Quote:
Originally Posted by saffierr
Sorry for double post, but I will explain it.
PHP код:
public OnPlayerConnect(playerid)
{
new string[350], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string,sizeof string, "%s has joined the server.", pName);
SetTimerEx("DelayedConnect", 2000, false, "i", playerid);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
forward DelayedConnect(playerid);
public DelayedConnect(playerid);
When I connect to my server, it says "(Name) has joined the server.", I want to have my name at the very least 
|
So you want to remove the "Connected to.. " ?
Re: How to create a new function -
saffierr - 23.08.2015
omg stupid me, WITHDRAWN. I am so dumb lol nvm this at all.
Although I'd like to learn how I can create an SetTimerEx Function. Just teach me how I can make such a fucntion please, and it'd be alright.
Re: How to create a new function -
Abagail - 23.08.2015
You already made the function, you just didn't place any code inside.
pawn Код:
forward DelayedFunction(playerid);
public DelayedFunction(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, 24);
new string[128];
format(string, sizeof string, "(%s) has joined the server.", pName);
SendClientMessageToAll(-1, string);
return 1;
}