SA-MP Forums Archive
[HELP] My Simple AFK System - 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)
+--- Thread: [HELP] My Simple AFK System (/showthread.php?tid=302731)



[HELP] My Simple AFK System - Phantomkiller - 10.12.2011

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



Re: [HELP] My Simple AFK System - Roberto Saviano - 10.12.2011

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.


Re: [HELP] My Simple AFK System - Phantomkiller - 10.12.2011

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


Re: [HELP] My Simple AFK System - Roberto Saviano - 10.12.2011

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

Sadly i cant


Re: [HELP] My Simple AFK System - suhrab_mujeeb - 10.12.2011

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.


Re: [HELP] My Simple AFK System - Phantomkiller - 10.12.2011

Okay, if it works u get rep


Re: [HELP] My Simple AFK System - suhrab_mujeeb - 10.12.2011

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