SA-MP Forums Archive
Dialog Help.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dialog Help.. (/showthread.php?tid=183739)



Dialog Help.. - Luis- - 16.10.2010

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



Re: Dialog Help.. - Austin - 16.10.2010

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

Maybe unix timestamp.


Re: Dialog Help.. - Mauzen - 16.10.2010

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.


Re: Dialog Help.. - Austin - 16.10.2010

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


Re: Dialog Help.. - cmg4life - 16.10.2010

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