help teleport
#7

Reworked how you processed the entire command because it was very sloppy, in my opinion.

Neaten up the code while you create things. It will help in the future for reading over, editing, and passing along code to others.

Plus, you were grabbing and setting variables that aren't always going to be true, therefore, narrow it down.

Hopefully this suffices your needs, if not, let me know.

Код:
CMD:goto(playerid, params[]) {

	new id;

	if ( GetPVarInt( playerid, "AdminLevel" ) < 1 )
			return SendClientMessage( playerid, -1, "You are not allowed to use this command!" );

	if ( sscanf( params, "u", id ) )
			return SendClientMessage( playerid, -1, "Usage : /goto [id/name]" );

	if ( IsPlayerConnected( id ) ) {

		new
			adminName[MAX_PLAYER_NAME],
			playerName[MAX_PLAYER_NAME],
			string[64],
			vehid,
			Float:x,
			Float:y,
			Float:z
		;

		GetPlayerPos( id, x, y, z );
		GetPlayerName( playerid, adminName, sizeof( adminName ) );
		GetPlayerName( id, playerName, sizeof( playerName ) );

		SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( id ) );
		SetPlayerInterior( playerid, GetPlayerInterior( id ) );

		if ( IsPlayerInAnyVehicle( playerid ) ) {

			vehid = GetPlayerVehicleID( playerid );
			SetVehiclePos( vehid, x + 2, y, z );

		} else {

			SetPlayerPos( playerid, x + 2, y, z );

		}

		format( string, sizeof( string ), "{FF4500}'%s' {FFFFFF}has teleported to you.", adminName );
		SendClientMessage( id, -1, string );

		format( string, sizeof( string ), "You teleported yourself to {FF4500}'%s'.", playerName );
		SendClientMessage( id, -1, string );


	} else {

		return SendClientMessage( playerid, -1, "Player is not connected." );

	}

	return 1;

}
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply


Messages In This Thread
help teleport - by asri - 16.07.2017, 15:59
Re: help teleport - by Logan0147 - 16.07.2017, 16:47
Re: help teleport - by SilverScripter - 16.07.2017, 16:51
Re: help teleport - by crukk11 - 16.07.2017, 21:19
Re: help teleport - by aoky - 16.07.2017, 21:29
Re: help teleport - by aoky - 16.07.2017, 21:32
Re: help teleport - by Daymen - 16.07.2017, 21:57
Re: help teleport - by asri - 19.07.2017, 02:21
Re: help teleport - by Daymen - 19.07.2017, 19:26
Re: help teleport - by asri - 22.07.2017, 11:01

Forum Jump:


Users browsing this thread: 3 Guest(s)