/settime command
#18

Quote:
Originally Posted by [MLT
Marco ]
ok thanks but where should i put it? under what i mean?
At the top of your script, under the '#include <......>' lines add:

pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Then at the very bottom of your script add the dcmd function:

pawn Код:
dcmd_settime(playerid,params[])
{
  if ( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You must be a Admin to use this Command !" );
  if ( !params[ 0 ] ) return SendClientMessage( playerid, COLOR_RED, "ERROR: /settime [hour]" );
  if ( !IsNumeric( params ) ) return SendClientMessage( playerid, COLOR_RED, "ERROR: The 'hour' parameter must be numerical" );  

  new
    string[ 70 ],
    h = strval( params );

  if ( h < 0 || h > 24 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: Use a number from 0 to 24" );
  SetWorldTime( h );
  format( string, sizeof( string ), "Admin %s has change the Time to %d !", GetName(playerid), h );
  SendClientMessageToAll( COLOR_HERE?????, string );
  return 1;
}
Then below this add these two custom functions also:

pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));

    return name;
}

stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
      if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
In your 'OnPlayerCommandText(...)' callback/event add:

pawn Код:
dcmd(settime, 7, cmdtext);
And apart from a typo or whatever we may have missed you are good to go. I take no credit for this btw, it's Littlejohnys code, I was just trying to improve it's speed etc.

Quote:
Originally Posted by ★ ♫ • Littlejohny • ♫ ★
Quote:
Originally Posted by Donny
No dude they are different, one is fast and uses less processing power and one is slow and uses too much.
BUT, the command is the same

- LJ
Hehehe ok I'll stop repeating myself, lets just agree to disagree dude.

Quote:
Originally Posted by Daren_Jacobson
that is a function, put it at the bottom, and put the dcmd(settime, 7, cmdtext); thing in OnPlayerCommandText

note:you must have
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
in your script (top of it, or close to top)
I'd already wrote all the above out so I'll post anyway.
Reply


Messages In This Thread
/settime command - by [MLT]Marco - 20.02.2009, 12:46
Re: /settime command - by MenaceX^ - 20.02.2009, 13:30
Re: /settime command - by [MLT]Marco - 20.02.2009, 14:09
Re: /settime command - by Littl3j0hNy - 20.02.2009, 14:15
Re: /settime command - by Donny_k - 20.02.2009, 14:52
Re: /settime command - by Littl3j0hNy - 20.02.2009, 14:54
Re: /settime command - by Donny_k - 20.02.2009, 15:09
Re: /settime command - by [MLT]Marco - 20.02.2009, 15:16
Re: /settime command - by Littl3j0hNy - 20.02.2009, 15:17
Re: /settime command - by Donny_k - 20.02.2009, 15:33
Re: /settime command - by Littl3j0hNy - 20.02.2009, 15:42
Re: /settime command - by Donny_k - 20.02.2009, 16:10
Re: /settime command - by [MLT]Marco - 20.02.2009, 16:18
Re: /settime command - by Daren_Jacobson - 20.02.2009, 16:23
Re: /settime command - by Littl3j0hNy - 20.02.2009, 16:55
Re: /settime command - by [MLT]Marco - 20.02.2009, 17:06
Re: /settime command - by Daren_Jacobson - 20.02.2009, 17:52
Re: /settime command - by Donny_k - 20.02.2009, 17:53
Re: /settime command - by Jason_Borne420 - 03.07.2009, 03:27
Re: /settime command - by Blacklite - 03.07.2009, 04:20
Re: /settime command - by Andom - 03.07.2009, 07:24
Re: /settime command - by [SFD]Marco - 03.07.2009, 08:07
Re: /settime command - by refshal - 03.07.2009, 08:16
Re: /settime command - by [SFD]Marco - 03.07.2009, 08:40
Re: /settime command - by refshal - 03.07.2009, 08:42
Re: /settime command - by [SFD]Marco - 03.07.2009, 08:45
Re: /settime command - by refshal - 03.07.2009, 08:47
Re: /settime command - by [SFD]Marco - 03.07.2009, 08:49
Re: /settime command - by refshal - 03.07.2009, 08:50
Re: /settime command - by [SFD]Marco - 03.07.2009, 08:51
Re: /settime command - by @TheShadow@ - 03.07.2009, 08:55
Re: /settime command - by refshal - 03.07.2009, 09:11
Re: /settime command - by Jason_Borne420 - 19.10.2009, 02:45
Re: /settime command - by homijs - 12.09.2010, 20:07
Respuesta: /settime command - by Alex_Obando - 03.04.2011, 19:17

Forum Jump:


Users browsing this thread: 3 Guest(s)