Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: Javpac on April 30, 2012, 06:17:43 am

Title: How to avoid crashes *?
Post by: Javpac 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
Title: Re: How to avoid crashes *?
Post by: SkillzVice-City 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
Title: Re: How to avoid crashes *?
Post by: Javpac on April 30, 2012, 05:25:16 pm
thanks, it worked   :P :P :P