24.02.2011, 15:57
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:
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.
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;
}
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.