How to create a new function
#1

How do I create an new SetTimerEx function?

Currently I want this function to create "DelayedConnect"
Reply
#2

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

Can you please explain more...what you wanna do?
Reply
#4

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

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.");
}
Reply
#6

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

Sorry for double post, but I will explain it.

PHP код:
public OnPlayerConnect(playerid)
{
     new 
string[350], pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    
format(string,sizeof string"%s has joined the server."pName);
    
SetTimerEx("DelayedConnect"2000false"i"playerid);
    
SendClientMessageToAll(COLOR_GREYstring);
    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
Reply
#8

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(playeridpNameMAX_PLAYER_NAME);
    
format(string,sizeof string"%s has joined the server."pName);
    
SetTimerEx("DelayedConnect"2000false"i"playerid);
    
SendClientMessageToAll(COLOR_GREYstring);
    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.. " ?
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)