OnPlayerText & sscanf for @
#1

Alright so Im trying to make a simple system that will work like
@SomePlayerName Hey bro

and then it would display the GameText to the other player, now my problem is quite simple, it will constantly reproduce the "Player is not connected". Now I know that its because first character is @ inside the string so it will basically check
if(IsPlayerConnected(@)

or for example if u type in @Twinki it will check if @Twinki is connected, how to resolve this?
PHP код:
public OnPlayerText(playeridtext[])
{
    
     if(
text[0] == '@') {
         new 
otherplayer;
        if(
sscanf(text,"u",otherplayer)) return SendClientMessage(playerid,COLOR_RED,"Usage: @Player_Name [message]");
        if(!
IsPlayerConnected(otherplayer)) return SendClientMessage(playeridCOLOR_RED,"Invalid playerid / not connected");
        new 
string[128];
        
format(string,sizeof(string),"%s mentioned you in the chat",GetName(playerid));
        
GameTextForPlayer(otherplayer,string,2000,4);
     }
    return 
1;

Reply


Messages In This Thread
OnPlayerText & sscanf for @ - by TwinkiDaBoss - 01.07.2016, 21:47
Re: OnPlayerText & sscanf for @ - by Vince - 01.07.2016, 21:51
Re: OnPlayerText & sscanf for @ - by TwinkiDaBoss - 01.07.2016, 21:54

Forum Jump:


Users browsing this thread: 1 Guest(s)