Fast question
#1

Hi guys.
I made a cool function. (/goafk and /back commands).
It works almost perfect, but there is one issue.
Here is what i have made so far:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    new currentvw; // Gets the current virtual world of the player
    new currentcolor; // Gets the current color of the player
 
    if (strcmp("/goafk", cmdtext, true, 10) == 0)
    {
        currentvw = GetPlayerVirtualWorld(playerid);
        currentcolor = GetPlayerColor(playerid);
        SetPlayerColor(playerid, COLOR_GREY);
        SetPlayerVirtualWorld(playerid, 5);
        TogglePlayerControllable(playerid, 0);
        GameTextForPlayer(playerid, "~r~Afk mode", 10000, 5);
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) You are now in AFK mode. Type /back to return");
        new name[MAX_PLAYER_NAME], string[44];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "( ! ) %s is now in AFK mode",name);
        SendClientMessageToAll(COLOR_GREY, string);
        return 1;
    }

    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, currentcolor);
        SetPlayerVirtualWorld(playerid, currentvw);
        TogglePlayerControllable(playerid, 1);
        GameTextForPlayer(playerid, "Welcome back", 3000, 5);
        new name[MAX_PLAYER_NAME], string[44];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "( ! ) %s is back from AFK mode",name);
        SendClientMessageToAll(COLOR_GREY, string);
        return 1;
    }
    return 0;
}
It works almost perfect. When you type /goafk, you come to virtual world 5. Your keys get disabled, so u cant move around, and your name-color turns grey.
Then when you type /back, you come to the past virtual world again and your keys gets enabled again. I want the name to turn into the color it had before typing /goafk again. I dont understand why this doesnt work, cus it works with the virtual world.
Hope you can help me. Thank you.
Reply
#2

Note :
Important Note: GetPlayerColor will return nothing unless SetPlayerColor has been used.
https://sampwiki.blast.hk/wiki/ColorFix
Reply
#3

Quote:
Originally Posted by maramizo
Посмотреть сообщение
Note :
Important Note: GetPlayerColor will return nothing unless SetPlayerColor has been used.
https://sampwiki.blast.hk/wiki/ColorFix
Thank you man! I love you!
Reply
#4

Haha np
Reply
#5

Also, you'll need to save it to a variable.
pawn Код:
new gpColor[ MAX_PLAYERS ];
To save the color
pawn Код:
gpColor[ playerid ] = GetPlayerColor( playerid );
To restore the player's color
pawn Код:
SetPlayerColor( playerid, gpColor[ playerid ] );
Reply
#6

Quote:
Originally Posted by Mean
Посмотреть сообщение
Also, you'll need to save it to a variable.
pawn Код:
new gpColor[ MAX_PLAYERS ];
To save the color
pawn Код:
gpColor[ playerid ] = GetPlayerColor( playerid );
To restore the player's color
pawn Код:
SetPlayerColor( playerid, gpColor[ playerid ] );
Okay. But i did it in another way, and that works. But thank you very much for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)