Usefull commands go here. Post and feel free. Strtok
Usefull for OnPlayerCommand text.
Put it on end of your script, just make sure it's not in a function!
Code
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Clear
Clears the chat.
Code
if(strcmp(cmdtext, "/clearchat", true) == 0)
{
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
SendClientMessage(playerid, COLOR_YELLOW, " ");
return 1;
}
Announce
Sends a GameText for everybody. Good for admins to announce something.
Code
if(strcmp(cmd, "/announce", true) == 0)
{
new name[256];
new tmp[256];
new tstring[256];
tmp = strtokspace(cmdtext, idx);
GetPlayerName(playerid,name,sizeof(name));
format(tstring, sizeof(tstring), "* %s: %s", name, tmp);
GameTextForAll(tmp, 5000, 3);
return 1;
}
Night
Changes the time to night time. Go on, wank a lil'
Code
if(strcmp(cmd, "/night", true) == 0)
{
SetWorldTime(0);
return 1;
}
Jordan
Jordan...
Code
if(strcmp(cmd, "/jordan", true) == 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "Huh?");
return 1;
}
Nothing hard.
P.S. Sorry for identation, the forum messes it all!
// Copied from my forum.