Problem with afk
#1

pawn Код:
CMD:afk(playerid, params[])
    {
        new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
        GetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
        SetPlayerInterior(playerid, 12);
        SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK, type /back to move again!");
        TogglePlayerControllable(playerid,0);
        label[playerid] = Create3DTextLabel("AFK",yellow,30.0,40.0,50.0,40.0,0);  //====This Is Line 312
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
        new string3[70];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string3, sizeof(string3), "%s is now Away from the keyboard!", name);
        SendClientMessageToAll(COLOR_YELLOW, string3);
    }
PHP код:
C:\Users\Danyal\dmgamemode.pwn(312) : error 017undefined symbol "label"
C:\Users\Danyal\dmgamemode.pwn(312) : warning 215expression has no effect
C
:\Users\Danyal\dmgamemode.pwn(312) : error 001expected token";"but found "]"
C:\Users\Danyal\dmgamemode.pwn(312) : error 029invalid expressionassumed zero
C
:\Users\Danyal\dmgamemode.pwn(312) : fatal error 107too many error messages on one line 
Reply
#2

You didn't define label.
Hard to read ?
Reply
#3

you need to add

pawn Код:
new Text3D:label
at the top of ur script
Reply
#4

Dude send full code.
Reply
#5

@umarmalik that is the full cmd code he just forgot to define the 3D text label
Reply
#6

above problem solved but here is new one
pawn Код:
CMD:afk(playerid, params[])
    {
        new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
        GetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
        SetPlayerInterior(playerid, 12);
        SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK, type /back to move again!");
        TogglePlayerControllable(playerid,0);
        label[playerid] = Create3DTextLabel("AFK",COLOR_YELLOW,30.0,40.0,50.0,40.0,0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
        new string3[70];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string3, sizeof(string3), "%s is now Away from the keyboard!", name);
        SendClientMessageToAll(COLOR_YELLOW, string3);
    }

CMD:back(playerid, params[])
    {
        new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
        SetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerInterior(playerid, 0);
        SendClientMessage(playerid, COLOR_YELLOW, "You are now back!");
        TogglePlayerControllable(playerid,1);
        new string3[70];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string3, sizeof(string3), "%s is now Back!", name);
        SendClientMessageToAll(COLOR_YELLOW, string3);
        Delete3DTextLabel(Text3D:label[playerid]);
        return 1;
    }
here is my code of afk system but now the problem is that when i type /afk it teleport me to interior that i want but on chat box there is written unknown command
and another thing when i type /back it doesnt teleport me to my place where i typed afk. it teleports me in air and player goes through ground
Reply
#7

Quote:
Originally Posted by shaikh007
Посмотреть сообщение
above problem solved but here is new one
pawn Код:
CMD:afk(playerid, params[])
    {
        new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
        GetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
        SetPlayerInterior(playerid, 12);
        SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK, type /back to move again!");
        TogglePlayerControllable(playerid,0);
        label[playerid] = Create3DTextLabel("AFK",COLOR_YELLOW,30.0,40.0,50.0,40.0,0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
        new string3[70];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string3, sizeof(string3), "%s is now Away from the keyboard!", name);
        SendClientMessageToAll(COLOR_YELLOW, string3);
    }

CMD:back(playerid, params[])
    {
        new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
        SetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
        SetPlayerInterior(playerid, 0);
        SendClientMessage(playerid, COLOR_YELLOW, "You are now back!");
        TogglePlayerControllable(playerid,1);
        new string3[70];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string3, sizeof(string3), "%s is now Back!", name);
        SendClientMessageToAll(COLOR_YELLOW, string3);
        Delete3DTextLabel(Text3D:label[playerid]);
        return 1;
    }
here is my code of afk system but now the problem is that when i type /afk it teleport me to interior that i want but on chat box there is written unknown command
and another thing when i type /back it doesnt teleport me to my place where i typed afk. it teleports me in air and player goes through ground
You are getting Unknown command because you didn't close the command afk with return 1; or return 0;
So add at the bottom of the afk command "return 1;"
Reply
#8

it is fixed now what about when i type /back i am in mid air and fall through ground it doesnot teleport me where i type /afk
Reply
#9

it is because you are teleporting them to an interior then setting their interior zone to 0 you need to either pick a designated place to teleport or save their last position
Reply
#10

You need to store LastY, LastX, LastZ. You are not storing anything. And why are you using 3 times MAX_PLAYERS? MAX_PLAYERS is uncommon in arrays, it is pretty much only used to loop things
Just add this

pawn Код:
new storePos[MAX_PLAYERS][3];
LastY = storePos[playerid][0];
LastX = storePos[playerid][1];
LastZ = storePos[playerid][2];
Remove these lines in /back

pawn Код:
new
        Float:LastX[ MAX_PLAYERS ],
        Float:LastY[ MAX_PLAYERS ],
        Float:LastZ[ MAX_PLAYERS ];
And replace
pawn Код:
SetPlayerPos(playerid, LastX[ playerid ], LastY[ playerid ], LastZ[ playerid ]);
with

pawn Код:
SetPlayerPos(playerid, storePos[playerid][0], storePos[playerid][1], storePos[playerid][2]);
Reply
#11

pawn Код:
new storePos[3];
        LastY = storePos[1];//====line 6
        LastX = storePos[0];
        LastZ = storePos[2];
pawn Код:
error 010: invalid function or declaration
Reply
#12

Quote:
Originally Posted by shaikh007
Посмотреть сообщение
pawn Код:
new storePos[3];
        LastY = storePos[1];//====line 6
        LastX = storePos[0];
        LastZ = storePos[2];
pawn Код:
error 010: invalid function or declaration
Ye, I edited it. You need to refresh page 1 and then re-check my post
I accidentally saved it as a global function
Reply
#13

save error still occur
pawn Код:
new storePos[MAX_PLAYERS][3];
LastY = storePos[playerid][0];  //==== line 6
LastX = storePos[playerid][1];
LastZ = storePos[playerid][2];
pawn Код:
error 010: invalid function or declaration
Reply
#14

some body help me please
Reply
#15

Dude use that afk filterscript code, maybe thats help you.

Код:
#include <a_samp>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#pragma tabsize 0


//Colors
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xFF0000AA
#define COLOR_LIGHTBLUE 		0x33CCFFAA
enum Player
{
    AFKstatus
}
new PlayerInfo[MAX_PLAYERS][Player];
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Simple AFK/BRB System By Sufyan \n Loading.....\nLoaded Successfully !");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

dcmd_afk(playerid, params[])
	{
	    #pragma unused params
		new string[256];
		if (PlayerInfo[playerid][AFKstatus] == 1)
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR: Your status is already AFK/BRB!");
			return 1;
		}

		else if (PlayerInfo[playerid][AFKstatus] == 0)
		{
			new pname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname, sizeof(pname));
			format(string, sizeof(string), "<!> {00C0FF}%s{FFFFFF}[{33AA33}ID:{F81414}%d{FFFFFF}]{00C0FF} is away from keyboard!", pname,playerid);
			SendClientMessageToAll(COLOR_WHITE, string);
			TogglePlayerControllable(playerid,0);
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
			PlayerInfo[playerid][AFKstatus] = 1;
			return 1;
 		}
return 0;
}

dcmd_brb(playerid, params[])
	{
	    #pragma unused params
		new string[256];
		if (PlayerInfo[playerid][AFKstatus] == 1)
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR: Your status is already AFK/BRB!");
			return 1;
		}

		else if (PlayerInfo[playerid][AFKstatus] == 0)
		{
			new pname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname, sizeof(pname));
			format(string, sizeof(string), "<!> {00C0FF}%s{FFFFFF}[{33AA33}ID:{F81414}%d{FFFFFF}]{00C0FF} will be right back!", pname,playerid);
			SendClientMessageToAll(COLOR_WHITE, string);
			TogglePlayerControllable(playerid,0);
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
			PlayerInfo[playerid][AFKstatus] = 1;
			return 1;
 }
return 0;
}

dcmd_back(playerid, params[])
	{
 		#pragma unused params
		new string [256];
		if (PlayerInfo[playerid][AFKstatus] == 0)
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR: Your status is already BACK!");
			return 1;
		}

		else if (PlayerInfo[playerid][AFKstatus] == 1)
		{
			new pname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname, sizeof(pname));
			format(string, sizeof(string), "<!> {00C0FF}%s{FFFFFF}[{33AA33}ID:{F81414}%d{FFFFFF}]{00C0FF} has returned!", pname,playerid);
			SendClientMessageToAll(COLOR_WHITE, string);
			TogglePlayerControllable(playerid,1);
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) - 50);
			PlayerInfo[playerid][AFKstatus] = 0;
			return 1;
 }
return 0;
}


dcmd_afkplayers( playerid, params[ ] )
{
    #pragma unused params
        new count = 0;
       	new name[MAX_PLAYER_NAME];
		new string[128];
        //
		SendClientMessage(playerid, COLOR_WHITE, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
 	 	SendClientMessage(playerid, COLOR_LIGHTBLUE, "AFK Players List:");
		SendClientMessage(playerid, COLOR_WHITE, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
        for(new i = 0; i < MAX_PLAYERS; i++)
		{
	 		if (IsPlayerConnected(i))
 			{

 			    if(PlayerInfo[i][AFKstatus] == 1)
 			    {
   					GetPlayerName(i, name, sizeof(name));
   					format(string, 256, "%s{FFFFFF}[{6EF83C}ID:{F81414}%d{FFFFFF}]", name,i );
					SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    				count++;
				}
			}
 			    
		}
		if (count == 0)
		{
		SendClientMessage(playerid, COLOR_RED, "There Are No Players in the AFK/BRB List");
		}
		SendClientMessage(playerid, COLOR_WHITE, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
		return 1;
}
					
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][AFKstatus] = 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][AFKstatus] = 0;
	return 1;
}



public OnPlayerText(playerid, text[])
{
	if (PlayerInfo[playerid][AFKstatus] == 1)
	{
		SendClientMessage(playerid, COLOR_RED, "You need to be /back to use the chatbox.");
		return 0;
	}

	else if (PlayerInfo[playerid][AFKstatus] == 0)
	{
		return 1;
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(afk,3,cmdtext);
	dcmd(brb,3,cmdtext);
	dcmd(back,4,cmdtext);
	dcmd(afkplayers,10,cmdtext);
	return 0;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)