Dialog Help..
#1

I made a /changespawn command so players can change there spawns but as it is a RP server I dont want it to be abused, I was thinking on setting a Timer for 24 hours.. How would I do it?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(listitem == 0)
        {
            SetPlayerPos(playerid, 1278.3571,168.0426,20.1642);
            SendClientMessage(playerid, COLOR_ALERT, "SERVER: You will now spawn in Red County");
        }
        else if(listitem == 1)
        {
            SetPlayerPos(playerid, 80.4938,1164.2931,18.6565,358.8586);
            SendClientMessage(playerid, COLOR_ALERT, "SERVER: You will now spawn in Fort Carson");
        }
        else if(listitem == 2)
        {
            SetPlayerPos(playerid, -92.8061,1227.8779,19.7422,178.0079);
            SendClientMessage(playerid, COLOR_ALERT, "SERVER: You will now spawn in Fort Carson");
        }
        return 1;
    }
    return 1;
}
Also
pawn Код:
if(!strcmp("/changespawn1", cmdtext, true, 13))
    {
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Changing your Spawn","Red County\nFort Carson 1\nFort Carson 2","Select","Cancel");
        return 1;
    }
Reply
#2

Record a variable for the player, save it so he can leave/rejoin and it'll be remembered.

Maybe unix timestamp.
Reply
#3

Just the short strategy:

Add a global variable, that holds the time of the last spawn change (with GetTickCount()). You will also have to store that value in the players ini.
Then, when he wants to change the spawn point, compare the stored time with the current tick time. If currenttime - storedtime < 86400000ms (24h) and > 0 (GetTickCount goes back to 0 every 24 days) abort the spawn change.
Reply
#4

Mauzen, no. This will mean that a server restart means they can reselect. You cannot go wrong with unix timestamps in this scenario.
Reply
#5

Just save the unix time when he disconnects in a file.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)