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.