Bugged CMD
#1

HI all need your help once again i have a problem with my /goto cmd. Soon as you try to tp to someone whos id is over id 3 it just tps you to id 3 so if i did /goto 4 im tped to id3 any ideas.

Many Thanks.

Code:
CMD:goto(playerid, params[])
{
	new string[256];
	if ( sscanf( params, "u", params[ 0 ]) )return SendClientMessage(playerid, COLOR_ORANGE, "You can use /pgoto <on/off> to disable enable people to come to you"),SendUsage( playerid, "/goto <id>" );
	if (P_DATA[ params[ 0 ] ][ P_Goto ] == 0 && P_DATA[ playerid ][ P_Level ] < 1 )return format(string,sizeof( string ), "ERROR: %s has the goto turned off.", PlayerName2( params[ 0 ])),SendClientMessage(playerid, COLOR_RED, string );
	if( params[ 0 ] == playerid )return SendError( playerid, "You cannot teleport to yourself!");
	new Float:ParamX, Float:ParamY, Float:ParamZ;

	GetPlayerPos( params[ 0 ], Float:ParamX, Float:ParamY, Float:ParamZ);
	SetCameraBehindPlayer( playerid );
	SetPlayerInterior( playerid, GetPlayerInterior( params[ 0 ] ));
	SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( params[ 0 ] ) );
	if(GetPlayerState(playerid) == 2){
		SetVehiclePos( GetPlayerVehicleID( playerid ), ParamX+2, ParamY, ParamZ );
		LinkVehicleToInterior( GetPlayerVehicleID( playerid ), GetPlayerInterior( params[ 0 ] ));
		SetVehicleVirtualWorld( GetPlayerVehicleID( playerid ) , GetPlayerVirtualWorld( params[ 0 ] ));
	} else {
	    SetPlayerPos( playerid, ParamX+2, ParamY, ParamZ );
	}

	FormMessageForAllEx(playerid && params[ 0 ],COLOR_GREEN, "%s teleported to %s!",PlayerName2( playerid ), PlayerName2( params[ 0 ] ));
	FormMessage( params[ 0 ], COLOR_GREEN, "%s teleported to you!",PlayerName2( playerid ) );
	FormMessage( playerid, COLOR_GREEN, "You teleported to %s!",PlayerName2( params[ 0 ] ) );

	return 1;
}
Reply
#2

Have you modified sscanf in any way?
Reply
#3

Nope ive even redownloaded it twice.
Reply
#4

Are you using 0.3d?
Reply
#5

No 0.3c R5
Reply
#6

try using a simple targetid variable
pawn Code:
CMD:goto(playerid, params[])
{
    new string[256],targetid;
    if ( sscanf( params, "u",targetid) )return SendClientMessage(playerid, COLOR_ORANGE, "You can use /pgoto <on/off> to disable enable people to come to you"),SendUsage( playerid, "/goto <id>" );
    if (P_DATA[targetid][ P_Goto ] == 0 && P_DATA[ playerid ][ P_Level ] < 1 )return format(string,sizeof( string ), "ERROR: %s has the goto turned off.", PlayerName2(targetid)),SendClientMessage(playerid, COLOR_RED, string );
    if(targetid == playerid )return SendError( playerid, "You cannot teleport to yourself!");
    new Float:ParamX, Float:ParamY, Float:ParamZ;

    GetPlayerPos(targetid, Float:ParamX, Float:ParamY, Float:ParamZ);
    SetCameraBehindPlayer( playerid );
    SetPlayerInterior( playerid, GetPlayerInterior(targetid));
    SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld(targetid) );
    if(GetPlayerState(playerid) == 2){
        SetVehiclePos( GetPlayerVehicleID( playerid ), ParamX+2, ParamY, ParamZ );
        LinkVehicleToInterior( GetPlayerVehicleID( playerid ), GetPlayerInterior(targetid));
        SetVehicleVirtualWorld( GetPlayerVehicleID( playerid ) , GetPlayerVirtualWorld(targetid));
    } else {
        SetPlayerPos( playerid, ParamX+2, ParamY, ParamZ );
    }

    FormMessageForAllEx(playerid && targetid,COLOR_GREEN, "%s teleported to %s!",PlayerName2( playerid ), PlayerName2( params[ 0 ] ));
    FormMessage( targetid, COLOR_GREEN, "%s teleported to you!",PlayerName2( playerid ) );
    FormMessage( playerid, COLOR_GREEN, "You teleported to %s!",PlayerName2(targetid) );

    return 1;
}
Reply
#7

Quote:
Originally Posted by park4bmx
View Post
try using a simple targetid variable
pawn Code:
CMD:goto(playerid, params[])
{
    new string[256],targetid;
    if ( sscanf( params, "u",targetid) )return SendClientMessage(playerid, COLOR_ORANGE, "You can use /pgoto <on/off> to disable enable people to come to you"),SendUsage( playerid, "/goto <id>" );
    if (P_DATA[targetid][ P_Goto ] == 0 && P_DATA[ playerid ][ P_Level ] < 1 )return format(string,sizeof( string ), "ERROR: %s has the goto turned off.", PlayerName2(targetid)),SendClientMessage(playerid, COLOR_RED, string );
    if(targetid == playerid )return SendError( playerid, "You cannot teleport to yourself!");
    new Float:ParamX, Float:ParamY, Float:ParamZ;

    GetPlayerPos(targetid, Float:ParamX, Float:ParamY, Float:ParamZ);
    SetCameraBehindPlayer( playerid );
    SetPlayerInterior( playerid, GetPlayerInterior(targetid));
    SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld(targetid) );
    if(GetPlayerState(playerid) == 2){
        SetVehiclePos( GetPlayerVehicleID( playerid ), ParamX+2, ParamY, ParamZ );
        LinkVehicleToInterior( GetPlayerVehicleID( playerid ), GetPlayerInterior(targetid));
        SetVehicleVirtualWorld( GetPlayerVehicleID( playerid ) , GetPlayerVirtualWorld(targetid));
    } else {
        SetPlayerPos( playerid, ParamX+2, ParamY, ParamZ );
    }

    FormMessageForAllEx(playerid && targetid,COLOR_GREEN, "%s teleported to %s!",PlayerName2( playerid ), PlayerName2( params[ 0 ] ));
    FormMessage( targetid, COLOR_GREEN, "%s teleported to you!",PlayerName2( playerid ) );
    FormMessage( playerid, COLOR_GREEN, "You teleported to %s!",PlayerName2(targetid) );

    return 1;
}
This didnt total help all it has done is soon as i try to tp to id3 or abose it says i cant tp to myself.
Reply
#8

Ok im trying another method but im getting some errors could someone help

Code:
CMD:goto(playerid, params[])
{
    new string[256],targetid;
    if ([ playerid ][ P_Level ] < 1 )return format(string,sizeof( string ), "ERROR: %s You Can Not Use This Command.", PlayerName2(targetid)),SendClientMessage(playerid, COLOR_RED, string );//7803 here
    if(targetid == playerid )return SendError( playerid, "You cannot teleport to yourself!");
    new Float:ParamX, Float:ParamY, Float:ParamZ;

    GetPlayerPos(targetid, Float:ParamX, Float:ParamY, Float:ParamZ);
    SetCameraBehindPlayer( playerid );
    SetPlayerInterior( playerid, GetPlayerInterior(targetid));
    SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld(targetid) );
    if(GetPlayerState(playerid) == 2){
        SetVehiclePos( GetPlayerVehicleID( playerid ), ParamX+2, ParamY, ParamZ );
        LinkVehicleToInterior( GetPlayerVehicleID( playerid ), GetPlayerInterior(targetid));
        SetVehicleVirtualWorld( GetPlayerVehicleID( playerid ) , GetPlayerVirtualWorld(targetid));
    } else {
        SetPlayerPos( playerid, ParamX+2, ParamY, ParamZ );
    }

    FormMessageForAllEx(playerid && targetid,COLOR_GREEN, "%s teleported to %s!",PlayerName2( playerid ), PlayerName2( params[ 0 ] ));
    FormMessage( targetid, COLOR_GREEN, "%s teleported to you!",PlayerName2( playerid ) );
    FormMessage( playerid, COLOR_GREEN, "You teleported to %s!",PlayerName2(targetid) );

    return 1;
}
Code:
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(2458) : warning 217: loose indentation
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(2481) : warning 217: loose indentation
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(7803) : error 029: invalid expression, assumed zero
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(7803) : warning 215: expression has no effect
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(7803) : error 001: expected token: ";", but found "]"
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(7803) : error 029: invalid expression, assumed zero
C:\Users\GTA ONLY\Desktop\SAMP\server backup\gamemodes\TE.pwn(7803) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
many thanks
Reply
#9

Line 2458 and 2481. Just fix your indentation, every coder should know what indentation means.

Line 7803, what line is that? I'm not going to look trough your whole code to find one single mistake
Reply
#10

Sorry only ment the errors and forgot the lines my bad. Ill edit the post with the lines.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)