[HELP] My Simple AFK System
#1

I made this AFK system and it works fine, but i need help going back... When im npr. at bank i type AFK and im afk, but when i type /back then im at same spot... Here is the script...
Код:
//AFK System
	if (!strcmp("/afk", cmdtext))
	{
	if(PlayerInfo[playerid][pAdmin] > 1)
	{
	new Float:cx, Float:cy, Float:cz;
	GetPlayerPos(playerid, cx, cy, cz);
	new string[256];
	new sendername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, sendername, sizeof(sendername));
	SetPlayerHealth(playerid, 10000)
	SetPlayerPos(playerid, 0,0,5)
	SetPlayerInterior(playerid, 5)
	format(string, sizeof(string), "* %s je Sada AFK.", sendername);
	SendClientMessageToAll(0xFFD700AA, string);
	}
	return 1;
	}

	if (!strcmp("/back", cmdtext))
	{
	if(PlayerInfo[playerid][pAdmin] > 1)
	{
	new string[256];
	new sendername[MAX_PLAYER_NAME];
	new Float:cx, Float:cy, Float:cz;
	GetPlayerName(playerid, sendername, sizeof(sendername));
	SetPlayerHealth(playerid, 50)
	SetPlayerPos(playerid, cx, cy, cz);
	SetPlayerInterior(playerid, 0)
	format(string, sizeof(string), "* %s Nije Vise AFK.", sendername);
	SendClientMessageToAll(0xFFD700AA, string);
	}
	return 1;
	}
Reply
#2

I believe the reason why this doesnt works is because you have done it as a local variable, and therefor you are basicly re-assigning another value to the variable, and therefor it doesnt gives the correct data.

If you create it into a global variable (At defines and all that) then it should work properly, however i dont know how to do that with setplayerposition, but i am pretty sure that is why.
Reply
#3

Can u send me pawn code fixed... That would be of much help...
Reply
#4

As stated above, i dont know exactly how to do this, if i could, i would of course help you.

Sadly i cant
Reply
#5

pawn Код:
//Top of your script
    new Float:cx[MAX_PLAYERS], Float:cy[MAX_PLAYERS], Float:cz[MAX_PLAYERS];
// Under you OnPlayerCommandText
if (!strcmp("/afk", cmdtext))
    {
    if(PlayerInfo[playerid][pAdmin] > 1)
    {
    GetPlayerPos(playerid, cx[playerid], cy[playerid], cz[playerid]);
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SetPlayerHealth(playerid, 10000)
    SetPlayerPos(playerid, 0,0,5)
    SetPlayerInterior(playerid, 5)
    format(string, sizeof(string), "* %s je Sada AFK.", sendername);
    SendClientMessageToAll(0xFFD700AA, string);
    }
    return 1;
    }

    if (!strcmp("/back", cmdtext))
    {
    if(PlayerInfo[playerid][pAdmin] > 1)
    {
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SetPlayerHealth(playerid, 50)
    SetPlayerPos(playerid, cx[playerid], cy[playerid], cz[playerid]);
    SetPlayerInterior(playerid, 0)
    format(string, sizeof(string), "* %s Nije Vise AFK.", sendername);
    SendClientMessageToAll(0xFFD700AA, string);
    }
    return 1;
    }
Try this, untested.
Reply
#6

Okay, if it works u get rep
Reply
#7

Quote:
Originally Posted by Phantomkiller
Посмотреть сообщение
Okay, if it works u get rep
Don't worry it will work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)