#1

Hello, When I type /goto command, I'm getting teleported to ID 0 everytime, even I type /goto [another player id]. Here's the code for /goto command.

Код HTML:
CMD:goto(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 2)
    {
		new targetid;
		if(sscanf(params, "u", targetid)) SendClientMessage(playerid,-1,""chat" /goto [playerid]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

		new Float:x,Float:y,Float:z,inter;
		GetPlayerPos(targetid,Float:x,Float:y,Float:z);
		inter = GetPlayerInterior(targetid);
        SetPlayerPosEx(playerid,Float:x,Float:y,Float:z,inter,0);
	}
	else {
		SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
	}
	return 1;
}
Reply
#2

Here's the one i use:

pawn Код:
CMD:goto(playerid, params[])
{
    new id;
    if(IsPlayerConnected(id))
    {
            if(!sscanf(params, "ui[125]", id))
            {
                new string[64];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                new Float:x, Float:y, Float:z;      GetPlayerPos(id,x,y,z); SetPlayerInterior(playerid,GetPlayerInterior(id));
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                format(string, sizeof(string), "You teleported yourself to %s .", PlayerName);
                SendClientMessage(playerid, -1, string);
                SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
                SetPlayerPos(playerid,x+2,y,z);

                return 1;
            }
            else return SendClientMessage(playerid, -1, "USAGE: /goto [PlayerId/PartOfName]");
    }
    else return SendClientMessage(playerid, -1, "Player is not connected.");
}
Other than that, i can see you use sscanf. Is it up to date?
Reply
#3

----------
Reply
#4

Quote:
Originally Posted by K3nX
Посмотреть сообщение
Use this, take some parts out considering of your GM.
PHP код:
CMD:goto(playerid,params[])
{
    if(
AdminLevel[playerid] >= 5) {
    new 
string[128];
    new 
ID;
    if(
sscanf(params,"u",ID))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /goto (Player Name/ID)");
        return 
1;
    }
    if(!
IsPlayerConnected(ID))
    {
        
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot goto them.",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    if(
IsSpawned[ID] != 1)
    {
        
format(string,sizeof(string),"%s(%d) is not spawned. You cannot goto dead people ..",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(ID,x,y,z);
    
    
SetPlayerPos(playerid,x+1,y,z);
    
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(ID));
    
SetPlayerInterior(playerid,GetPlayerInterior(ID));
    
format(string,sizeof(string),"You have teleported to %s(%d).",PlayerName(ID),ID);
    
SendClientMessage(playerid,COLOR_ADMIN,string);
    }
    return 
1;

a lot useless lines which takes from memory
pawn Код:
CMD:goto(playerid,params[])
{
    if(AdminLevel[playerid] < 5) return 0; //or return 1
    new string[128],ID;
    if(sscanf(params,"u",ID)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /goto (Player Name/ID)");
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot goto them.",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(IsSpawned[playerid] != 1) return SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s(%d) is not spawned. You cannot goto dead people ..",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    new Float:x,Float:y,Float:z;
    GetPlayerPos(ID,x,y,z);
    SetPlayerPos(playerid,x+1,y,z);
    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(ID));
    SetPlayerInterior(playerid,GetPlayerInterior(ID));
    format(string,sizeof(string),"You have teleported to %s(%d).",PlayerName(ID),ID);
    SendClientMessage(playerid,COLOR_ADMIN,string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)