Command /goto and command /get doesnt work.
#1

Hello!

When I type /goto [ID] or /get[ID] I always got [ERROR]Player not connected but in reality he is.Both commands have same issue.

CMD:goto

Код:
CMD:goto(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] == 0)return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    new targetid;
    if(sscanf(params,"d",targetid))return SendClientMessage(playerid, COLOR_YELLOW, "Usage:{FFFFFF} /goto [ID]");
    if(IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player not connected");
    if(pInfo[targetid][USER_LOGGED_IN] == 0)return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in");
    new Float:x, Float:y, Float:z, interior = GetPlayerInterior(targetid), vworld = GetPlayerVirtualWorld(targetid);
    GetPlayerPos(targetid, x, y, z);
    SetPlayerInterior(playerid, interior);
    SetPlayerVirtualWorld(playerid, vworld);
    SetPlayerPos(playerid, x +1, y +1, z);
    SendClientMessage(playerid, COLOR_ADMIN, "You have been teleported successfully!");
    return 1;
}
CMD:get

Код:
CMD:get(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 2)return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
	new pName[MAX_PLAYER_NAME];
	new string[128], targetid;
    if(sscanf(params,"d",targetid))
	{
 		SendClientMessage(playerid, COLOR_YELLOW, "Usage:{FFFFFF} /get [ID]");
 		return 1;
	}
    if(IsPlayerConnected(targetid))
 	{
		SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player not connected");
		return 1;
 	}
	if(pInfo[targetid][USER_LOGGED_IN] == false)
	{
	    SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in");
	    return 1;
	}
	if(pInfo[playerid][Adminlevel] >= 2 || IsPlayerAdmin(playerid))
    {
		new Float:x,Float:y,Float:z, interior = GetPlayerInterior(playerid), vworld = GetPlayerVirtualWorld(playerid);
		GetPlayerPos(playerid, x,y,z);
		SetPlayerInterior(targetid, interior);
		SetPlayerVirtualWorld(targetid, vworld);
		SetPlayerPos(targetid, x+1, y+1, z);
		GetPlayerName(targetid, pName, sizeof(pName));
		format(string, sizeof(string), "[ADMIN]{FFFFFF} %s has been successfully teleported!", pName);
		SendClientMessage(playerid, COLOR_ADMIN, string);
	}
	return 1;
}
Please someone fix it.THanks!
Reply
#2

Your issue is this (in the /goto command):

pawn Код:
if(IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player not connected");
That is the same as (what is in your /get command):
pawn Код:
if(IsPlayerConnected(targetid))//Check if they are connected
{
      SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF}Player not connected");//if they are send this message
      return 1;//end the code
}
Simple add a ! before it :
pawn Код:
if(!IsPlayerConnected(targetid))//THIS will check if they are NOT connected, rather than are.

Clean code is good code.
Reply
#3

Thanks,it works now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)