Noobie Question
#1

Hey,another noobie question
i've tried to make an afk cmd,and it came totally wrong.
i don't know a lot about strings and all,but,i tried to make SetPlayerName,like i done with SendClientMessageToAll,idk,i probably done something really wrong.look what i've tried:
pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        new name[MAX_PLAYER_NAME], string[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s.", name );
    SetPlayerName(playerid,string);
    format(string, sizeof(string), "%s is Afk,:(.", name );
    SendClientMessageToAll(GREEN,string);
    }
There are no errors.
what suppose to happen,is that when someone types /afk,his name will become [AFK]Name.or something..
and when i type /AFK it's only sending the message,but nothing happens with the name 0.0
Yes i know,there are a lot of topics like that,but i didnt see any solution in the comments o_O..
And they were old,so i didnt want to post a comment there,i just started a new topic.
And don't laugh at me,im really noobie at scripting.

Help appreciated,Thanks in advance.
Reply
#2

pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        new name[MAX_PLAYER_NAME], string[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s.", name );
    SetPlayerName(playerid,string);
    format(string, sizeof(string), "%s is Afk,:(.", name );
    SendClientMessageToAll(GREEN,string);
    return 1;
    }
Try that?
Reply
#3

Quote:
Originally Posted by mavtias
pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        new name[MAX_PLAYER_NAME], string[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s.", name );
    SetPlayerName(playerid,string);
    format(string, sizeof(string), "%s is Afk,:(.", name );
    SendClientMessageToAll(GREEN,string);
    return 1;
    }
Try that?
Sorry,didnt work too,still nothing happens with the name
Reply
#4

pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        new name[MAX_PLAYER_NAME], string[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s.", name );
    SetPlayerName(playerid,"%s",string);
    format(string, sizeof(string), "%s is Afk,:(.", name );
    SendClientMessageToAll(GREEN,string);
    return 1;
    }
Reply
#5

Quote:
Код:
if(strcmp("/afk", cmdtext, true, 10) == 0)
{
}
/ a f k has 4 characters, not 10.

pawn Код:
if(strcmp("/afk", cmdtext, true, 4) == 0)
{
  // your command
}
Reply
#6

pawn Код:
if (strcmp("/afk", cmdtext, true, 4) == 0)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s.", name);
    SetPlayerName(playerid, string);
    format(string, sizeof(string), "%s is Afk,:(.", name);
    SendClientMessageToAll(GREEN, string);
    return 1;
}
Try this.
Reply
#7

Nothing is working

But thank you for your trying to help anyway..
Reply
#8

pawn Код:
if (strcmp("/afk", cmdtext, true, 4) == 0)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s is Afk,:(.", name);
    SendClientMessageToAll(GREEN, string);
    format(string, sizeof(string),"[AFK]%s", name);
    SetPlayerName(playerid, string);
    return 1;
}
This one IS working There you go
P.S I moved the Message before It sets the name, so It says "3xPloSioNxXx is Afk ." instead of "[AFK]3xPloSioNxXx is Afk ."
Reply
#9

Quote:
Originally Posted by mavtias
pawn Код:
if (strcmp("/afk", cmdtext, true, 4) == 0)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s is Afk,:(.", name);
    SendClientMessageToAll(GREEN, string);
    format(string, sizeof(string),"[AFK]%s", name);
    SetPlayerName(playerid, string);
    return 1;
}
This one IS working There you go
P.S I moved the Message before It sets the name, so It says "3xPloSioNxXx is Afk ." instead of "[AFK]3xPloSioNxXx is Afk ."
Dude,thank you so much,it worked!
Reply
#10

Lol
Now,i built a /back cmd,and when i type /back,it sends :"[AFK]3xPloSioNxXx is back,YEY! "
and im still [AFK] lol.here is the code:
pawn Код:
if (strcmp("/back", cmdtext, true, 4) == 0)
    {
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s is back,YEY :D.", name);
    SendClientMessageToAll(GREEN, string);
    format(string, sizeof(string),"%s", name);
    SetPlayerName(playerid, string);
    return 1;
    }
Thanks in advance
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)