/gethere bug
#1

I added this to my gamemode and it doesnt teleport the player to my location, it teleports me to them

Код:
CMD:gethere(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
    new id; 
    if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0x333666, "Correct usage: /gethere [ID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0x333666, "Invalid playerid"); 
    new Float:Pos[4], string[45], playeridname[MAX_PLAYER_NAME+1], idname[MAX_PLAYER_NAME+1];
    SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id)); 
    SetPlayerInterior(playerid, GetPlayerInterior(id)); 
    GetPlayerPos(id, Pos[0], Pos[1], Pos[2]); 
    GetPlayerFacingAngle(id, Pos[3]); 
    SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); 
    SetPlayerFacingAngle(playerid, Pos[3]); 
    GetPlayerName(id, idname, sizeof(idname)); 
    format(string, sizeof(string), "You have teleported %s to you.", idname); 
    SendClientMessage(playerid, 0x333666, string); 
    GetPlayerName(playerid, playeridname, sizeof(playeridname));
    format(string, sizeof(string), "%s has teleported you to them", playeridname); 
    SendClientMessage(id, 0x333666, string); 
    }
    else
    {
	    SendClientMessage(playerid, COLOR_RED, "You cannot use that command");
    }
    return 1;
}
Reply
#2

Take a look at mine:

pawn Код:
CMD:gethere(playerid, params[])
{
    new playerb, string[128];
    new Float:Pos[3];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [playerid]");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
    if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    if(IsPlayerInAnyVehicle(playerb) && GetPlayerState(playerb) == PLAYER_STATE_DRIVER && !GetPlayerInterior(playerid))
    {
        SetVehiclePos(GetPlayerVehicleID(playerb), Pos[0]+2, Pos[1]+2, Pos[2]);
    }
    else
    {
        SetPlayerPos(playerb, Pos[0]+1, Pos[1], Pos[2]);
    }
    SetPlayerInterior(playerb, GetPlayerInterior(playerid));
    SetPlayerVirtualWorld(playerb, GetPlayerVirtualWorld(playerid));
    format(string, sizeof(string), " You have teleported %s to you.", RPN(playerb));
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string, sizeof(string), " You have been teleported to admin %s.", RPN(playerid));
    SendClientMessage(playerb, COLOR_WHITE, string);
    return 1;
}
Reply
#3

PHP код:
CMD:gethere(playeridparams[])
{    
    new 
playerbstring[128];
    new 
Float:Pos[3];
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    if(
sscanf(params"u"playerb)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /goto [playerid]");
    if(
PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playeridCOLOR_GREY"Player has a higher admin level than you.");
    
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
    if(
IsPlayerInAnyVehicle(playerb) && GetPlayerState(playerb) == PLAYER_STATE_DRIVER && !GetPlayerInterior(playerid))
    {
        
SetVehiclePos(GetPlayerVehicleID(playerb), Pos[0]+2Pos[1]+2Pos[2]);
    }
    else
    {
        
SetPlayerPos(playerbPos[0]+1Pos[1], Pos[2]);
    }
    
SetPlayerInterior(playerbGetPlayerInterior(playerid));
    
SetPlayerVirtualWorld(playerbGetPlayerVirtualWorld(playerid));
    return 
1;

Reply
#4

Thankyou! but theres one problem
Код:
C:\Users\Michael\Desktop\Roleplay\gamemodes\Wildside.pwn(1290) : error 017: undefined symbol "RPN"
C:\Users\Michael\Desktop\Roleplay\gamemodes\Wildside.pwn(1292) : error 017: undefined symbol "RPN"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#5

Quote:
Originally Posted by Michael_Cuellar
Посмотреть сообщение
Thankyou! but theres one problem
Код:
C:\Users\Michael\Desktop\Roleplay\gamemodes\Wildside.pwn(1290) : error 017: undefined symbol "RPN"
C:\Users\Michael\Desktop\Roleplay\gamemodes\Wildside.pwn(1292) : error 017: undefined symbol "RPN"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Remove the RPN, it's a variable I use on my script.
Reply
#6

fixed it!, thanks josh and eastoak,
plus Repp
Reply
#7

No problem, man. Need any more help? PM me.
Reply
#8

Just to tell you where you went wrong.

pawn Код:
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
    SetPlayerInterior(playerid, GetPlayerInterior(id));
    GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
    GetPlayerFacingAngle(id, Pos[3]);
    SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    SetPlayerFacingAngle(playerid, Pos[3]);
You have mixed up 'playerid' and 'id', the correct code is:
pawn Код:
SetPlayerVirtualWorld(id, GetPlayerVirtualWorld(playerid)); //Set target to your vw, not your vw to the target's
    SetPlayerInterior(id, GetPlayerInterior(playerid)); //Set target to your interior, not your interior to the target's
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); //Get your position
    GetPlayerFacingAngle(playerid, Pos[3]); //Get your angle
    SetPlayerPos(id, Pos[0], Pos[1], Pos[2]); //Set the target to this position
    SetPlayerFacingAngle(id, Pos[3]); //Set the target to this angle
id (target) = Player you are trying to teleport.
playerid (you) = Your player
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)