Author Topic: How to avoid crashes *?  (Read 2673 times)

0 Members and 1 Guest are viewing this topic.

Offline Javpac

  • Street Thug
  • *
  • Posts: 5
    • View Profile
    • [CS] Clan
How to avoid crashes *?
« on: April 30, 2012, 06:17:43 am »
Hi I would like to know how you can avoid that when someone comes with a name that carries * ejm: kill *, I crashee the server, thanks in advance

PS: sorry for my bad English

Offline SkillzVice-City

  • Street Thug
  • *
  • Posts: 7
  • The Boss & O.C
    • View Profile
Re: How to avoid crashes *?
« Reply #1 on: April 30, 2012, 02:26:27 pm »
[pawn]
public IsInvalidChar( c[ ] )
{
   if (strfind(c, "*", true) != -1 ||
       strfind(c, "?", true) != -1 ||
       strfind(c, ">", true) != -1 ||
       strfind(c, "<", true) != -1 ||
       strfind(c, "ยก", true) != -1 ||
       strfind(c, "/", true) != -1) return 1;
   if (isNumeric(c)) return 1;
        else return 0;
    return 1;
 }


public NickPlayerChar(playerid)
{
    if(IsInvalidChar(PlayerName(playerid))) {
      new str[256];
      format(str,256,"*Auto-kick %s reason: [Invalid Nick-name]", PlayerName(playerid));
      SendClientMessageToAll(RED,str);
      Kick(playerid);
   }
}




stock PlayerName(playerid)
{
      new name[24];
      GetPlayerName(playerid,name,24);
      return name;
}





[/pawn]

[pawn]

public OnPlayerConnect(playerid)
{
NickPlayerChar(playerid);
return 1;
}
[/pawn]

made by Madara
« Last Edit: April 30, 2012, 02:29:36 pm by SkillzVice-City »
-

Offline Javpac

  • Street Thug
  • *
  • Posts: 5
    • View Profile
    • [CS] Clan
Re: How to avoid crashes *?
« Reply #2 on: April 30, 2012, 05:25:16 pm »
thanks, it worked   :P :P :P