convert /mytime
#6

Quote:
Originally Posted by toi
Посмотреть сообщение
I do not use sscanf, what can I use instead?
You could use a function named 'strtok', but it's old and outdated, sscanf is the best way to go.

https://sampwiki.blast.hk/wiki/Strtok

Or you could try this:

pawn Код:
//Near the top of your script

#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mytime", cmdtext, true, 6) == 0)
    {
        new Time;
        if ( P_DATA[ playerid ][ P_Logged ] == 0 )
            return SendError( playerid, "You must be logged in to change your time! ~n~Type ~b~~h~/login.");

        if ( isnull( cmdtext[7] ) ) //If it doesn't work try changing it to 'cmdtext[8]'
            return SendUsage( playerid, "/mytime <hour>");
       
        Time = strval( cmdtext[7] ); //Again change it to 'cmdtext[8]' if it doesn't work.

        if ( Time < 0 || Time > 24 )
            return SendError( playerid, "~n~Numbers must be from ~b~~h~0 ~w~to ~b~~h~24");

        P_DATA[ playerid ][ P_Time ] = Time;
        SetPlayerTime( playerid, Time, 0 );

        new String[ 160 ];
        format( String, sizeof String, "You have changed your time to ~b~~h~%d~w~:~b~~h~00~w~. It has been saved into your account, on next login this time will be applied.", Time );
        Info( playerid,  String, 5000);

        new iUID = BUD::GetNameUID( PlayerName2( playerid ) );
        BUD::SetIntEntry(iUID, "Time", Time);
        return 1;
    }
    return 0;
}
Reply


Messages In This Thread
convert /mytime - by toi - 28.02.2013, 18:41
Re: convert /mytime - by Bicentric - 28.02.2013, 18:46
Re: convert /mytime - by toi - 28.02.2013, 18:57
Re: convert /mytime - by Bicentric - 28.02.2013, 19:00
Re: convert /mytime - by toi - 28.02.2013, 19:05
Re: convert /mytime - by Bicentric - 28.02.2013, 19:13

Forum Jump:


Users browsing this thread: 1 Guest(s)