SA-MP Forums Archive
Noobie Question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Noobie Question (/showthread.php?tid=99361)



Noobie Question - [XST]O_x - 27.09.2009

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.


Re: Noobie Question - Mike Garber - 27.09.2009

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?


Re: Noobie Question - [XST]O_x - 27.09.2009

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


Re: Noobie Question - Mike Garber - 27.09.2009

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;
    }



Re: Noobie Question - Correlli - 27.09.2009

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
}



Re: Noobie Question - Tr1viUm - 27.09.2009

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.


Re: Noobie Question - [XST]O_x - 27.09.2009

Nothing is working

But thank you for your trying to help anyway..


Re: Noobie Question - Mike Garber - 27.09.2009

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 ."


Re: Noobie Question - [XST]O_x - 27.09.2009

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!


Re: Noobie Question - [XST]O_x - 27.09.2009

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