2 little questions
#1

Hello, I would like to know how can I use part of name in my commands like for example the command stats. If a player name is "HowCanIMakeIt" and I use "/stats make" or "/stats owcani" It show his stats and if there multiple names ill just make a error saying "multiple names found".

My second question is if I use a command on a non-connected player, how can I make it show the invalid name like if I use /stats helloyou, I'll will return "helloyou is not connected to the server."
It would be awsome if you could give me some tips how to make it.

This is my try for the second question.

pawn Код:
if(!IsPlayerConnected(target))
{
        GetPlayerName(target,pname,MAX_PLAYER_NAME);
        format(string,sizeof(string),"The Player %s is not connected to the server.",pname);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
 }
Reply
#2

Use sscanf by ******. It is made for these kinda things
Reply
#3

I already use sscanf but for the part of name it only work if you use the first letters like "/stats how" and "/stats cani" won't work.
Reply
#4

Use the u parameter of sscanf
Reply
#5

pawn Код:
if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"USAGE : /stats [ID/Part of Name]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-1,"Player is not connected");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)