Post any usefull snippets here. Let me start: Connect message
Sends an icon on the right side that the player has joined the server.
Code
public OnPlayerConnect(playerid)
{
SendDeathMessage(playerid, INVALID_PLAYER_ID, 200);
return 1;
}
Disconnect message
Sends an icon on the right side that the player has left the server.
Code
public OnPlayerDisconnect(playerid)
{
SendDeathMessage(playerid, INVALID_PLAYER_ID, 201);
return 1;
}
Hackers ban
Bans a player if they try to crash the server.
Code
Words(string[])
{
new idx,words;
while(strlen(strtok(string,idx))) words++;
return words;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
for(new i=0, j=Words(cmdtext), idx; i<j; i++)
{
new tmpstr[256];
tmpstr = strtok(cmdtext, idx);
if(isNumeric(tmpstr) && strlen(tmpstr) > 49)
{
Ban(playerid);
return 1;
}
}
}
Forum mess up the identation, sorry.
// Copied from my forum.