SA-MP Forums Archive
afk / back 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: afk / back system (/showthread.php?tid=276372)



afk / back system - Zonoya - 13.08.2011

hey guys i made a afk / back system code under this line but my problem is i want when the player types afk it saves his cords and when he types back he gets teleported back to his cords here is my script the afk works he gets teled but when i type back i goto blueberry acres

Код:
	if(strcmp(cmdtext, "/afk", true) == 0) {
		GetPlayerPos(playerid, x, y, z);
		SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
		SetPlayerInterior(playerid, 12);
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
		new string[128]; // Creating the string.
		GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
		format(string, sizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
		SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
		TogglePlayerControllable(playerid, 0); // Makes it so the player cannot move.
		SetPlayerHealth(playerid, 999999.999); // Sets the players health so he is invincible! So noone can kill him.
		return 1;
	}
    if(strcmp(cmdtext, "/back", true) == 0)
    {
        SetPlayerPos(playerid, x, y, z);
        SetPlayerInterior(playerid, 0);
 		new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
		new string[128]; // Creating the string.
		GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
		format(string, sizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
		SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
		TogglePlayerControllable(playerid, 1); // Makes it so the player can move.
		SetPlayerHealth(playerid, 100); // Sets the players health back to normal. He is now killable.
		return 1;
	}



Re: afk / back system - Raimis_R - 13.08.2011

pawn Код:
new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];

    if(strcmp(cmdtext, "/afk", true) == 0) {
        GetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
        SetPlayerInterior(playerid, 12);
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
        SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        TogglePlayerControllable(playerid, 0); // Makes it so the player cannot move.
        SetPlayerHealth(playerid, 999999.999); // Sets the players health so he is invincible! So noone can kill him.
        return 1;
    }
    if(strcmp(cmdtext, "/back", true) == 0)
    {
        SetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerInterior(playerid, 0);
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
        SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        TogglePlayerControllable(playerid, 1); // Makes it so the player can move.
        SetPlayerHealth(playerid, 100); // Sets the players health back to normal. He is now killable.
        return 1;
    }



Re: afk / back system - Zonoya - 13.08.2011

im still taken back to Blueberry acres


Re: afk / back system - Raimis_R - 13.08.2011

Do you have added

pawn Код:
new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
I can say this script 100% working.


Re: afk / back system - Zonoya - 13.08.2011

yes i added i get taken to blueberry


Re: afk / back system - Raimis_R - 13.08.2011

Something you doing wrong.

http://pastebin.com/m4R2zxfh


Re: afk / back system - Zonoya - 13.08.2011

ill show u the current script then

Код:
	new
        	Float:LastX[ MAX_PLAYERS ],
	        Float:LastY[ MAX_PLAYERS ],
	        Float:LastZ[ MAX_PLAYERS ];

    if(strcmp(cmdtext, "/afk", true) == 0) {
        GetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
        SetPlayerInterior(playerid, 12);
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
        SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        TogglePlayerControllable(playerid, 0); // Makes it so the player cannot move.
        SetPlayerHealth(playerid, 999999.999); // Sets the players health so he is invincible! So noone can kill him.
        return 1;
    }
    if(strcmp(cmdtext, "/back", true) == 0)
    {
        SetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerInterior(playerid, 0);
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
        SendClientMessageToAll(COLOR_BLUE, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        TogglePlayerControllable(playerid, 1); // Makes it so the player can move.
        SetPlayerHealth(playerid, 100); // Sets the players health back to normal. He is now killable.
        return 1;
    }
but when i type back im at blueberry




Re: afk / back system - Raimis_R - 13.08.2011

At first you need to type /afk and then /back

BTW I have tested script working good.


Re: afk / back system - Zonoya - 13.08.2011

yeah i just retried and it works ty +rep to u


Re: afk / back system - Zonoya - 13.08.2011

can u help me with this script please i want to spawn random cars when someone types /call but no cars spawn let alone random cars

Код:
		if(strcmp("/Call", cmdtext, true, 3) == 0)
		{
		    new Float:x, Float:y, Float:z;
			CreateVehicle(411, x+3, y, z, 180, 1, 1, 100);
    		SendClientMessage(playerid, Yellow,"You have Dialed The Car Agencey you will now be spawned a car");
			return 1;
		}



Re: afk / back system - Raimis_R - 13.08.2011

Try

pawn Код:
if(strcmp("/Call", cmdtext, true, 3) == 0)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos( playerid, x, y, z );
    CreateVehicle( 400+random( 211 ), x+3, y, z, 180, 1, 1, 100);
    SendClientMessage(playerid, Yellow,"You have Dialed The Car Agencey you will now be spawned a car");
    return 1;
}



Re: afk / back system - Zonoya - 13.08.2011

it works thanks