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
#2

Then either start from text[1] or put the @ in the specifier: "'@'u". You also need to add a string specifier to capture the chat. You can use a quiet specifier (enclose it in curly braces) if you're not interested in the text itself.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Then either start from text[1] or put the @ in the specifier: "'@'u". You also need to add a string specifier to capture the chat. You can use a quiet specifier (enclose it in curly braces) if you're not interested in the text itself.
Yeaaah I forgot about the '@' inside sscanf, damn been long time haha. Thanks a lot bud
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)