PDA

View Full Version : help teleport


asri
16/07/2017, 03:59 PM
CMD:goto(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if ( GetPVarInt( playerid, "AdminLevel" ) < 1)
return SendClientMessage( playerid, -1, "You are not allowed to use this command!");
{
if(!sscanf(params, "ui", id))
{
new string[64];
new vehid = GetPlayerVehicleID(playerid);;
new name[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerPos(id,x,y,z);
GetVehiclePos(vehid,x,y,z);
SetPlayerInterior(playerid,GetPlayerInterior(id));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), ""ORANGESV"%s {FFFFFF}teleported his self to you.", name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You teleported yourself to "ORANGESV"%s.", PlayerName);
SendClientMessage(playerid, -1, string);
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWor ld(id));
SetPlayerPos(playerid,x+2,y,z);
SetVehiclePos(vehid,x+2,y,z);
PutPlayerInVehicle(playerid, vehid, 0);
return 1;
}
else return SendClientMessage(playerid, -1, "Usage : /goto [id/name]");
}
}
else return SendClientMessage(playerid, -1, "Player is not connected.");
}

C:\Users\cyber\Desktop\New Text Document.txt(3403) : error 036: empty statement
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 017: undefined symbol "ORANGESV"
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 029: invalid expression, assumed zero
C:\Users\cyber\Desktop\New Text Document.txt(3412) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase

Logan0147
16/07/2017, 04:47 PM
remove the second ";"

new vehid = GetPlayerVehicleID(playerid);;

Make sure that "ORANGESV" is defined, also check that (http://forum.sa-mp.com/showthread.php?t=196360) for more help

SilverScripter
16/07/2017, 04:51 PM
PHP Code:
CMD:goto(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if ( GetPVarInt( playerid, "AdminLevel" ) < 1)
return SendClientMessage( playerid, -1, "You are not allowed to use this command!");
{
if(!sscanf(params, "ui", id))
{
new string[64];
new vehid = GetPlayerVehicleID(playerid);;
new name[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerPos(id,x,y,z);
GetVehiclePos(vehid,x,y,z);
SetPlayerInterior(playerid,GetPlayerInterior(id));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), ""ORANGESV"%s {FFFFFF}teleported his self to you.", name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You teleported yourself to "ORANGESV"%s.", PlayerName);
SendClientMessage(playerid, -1, string);
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWor ld(id));
SetPlayerPos(playerid,x+2,y,z);
SetVehiclePos(vehid,x+2,y,z);
PutPlayerInVehicle(playerid, vehid, 0);
return 1;
}
else return SendClientMessage(playerid, -1, "Usage : /goto [id/name]");
}
}
else return SendClientMessage(playerid, -1, "Player is not connected.");
}
Quote:
C:\Users\cyber\Desktop\New Text Document.txt(3403) : error 036: empty statement
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 017: undefined symbol "ORANGESV"
C:\Users\cyber\Desktop\New Text Document.txt(3412) : error 029: invalid expression, assumed zero
C:\Users\cyber\Desktop\New Text Document.txt(3412) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



/************|TRY THIS|**************/
#define ORANGESV
CMD:goto(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if ( GetPVarInt( playerid, "AdminLevel" ) < 1)
return SendClientMessage( playerid, -1, "You are not allowed to use this command!");
{
if(!sscanf(params, "ui", id))
{
new string[64];
new vehid = GetPlayerVehicleID(playerid);;
new name[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerPos(id,x,y,z);
GetVehiclePos(vehid,x,y,z);
SetPlayerInterior(playerid,GetPlayerInterior(id));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), ""ORANGESV"%s {FFFFFF}teleported his self to you.", name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You teleported yourself to "ORANGESV"%s.", PlayerName);
SendClientMessage(playerid, -1, string);
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWor ld(id));
SetPlayerPos(playerid,x+2,y,z);
SetVehiclePos(vehid,x+2,y,z);
PutPlayerInVehicle(playerid, vehid, 0);
return 1;
}
else return SendClientMessage(playerid, -1, "Usage : /goto [id/name]");
}
}
else return SendClientMessage(playerid, -1, "Player is not connected.");
}

crukk11
16/07/2017, 09:19 PM
Use php code

aoky
16/07/2017, 09:29 PM
Wrong, will repost in a second.

aoky
16/07/2017, 09:32 PM
Try this:

CMD:goto(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if ( GetPVarInt( playerid, "AdminLevel" ) < 1)
return SendClientMessage( playerid, -1, "You are not allowed to use this command!");
{
if(!sscanf(params, "ui", id))
{
new string[64];
new vehid = GetPlayerVehicleID(playerid);
new name[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerPos(id,x,y,z);
GetVehiclePos(vehid,x,y,z);
SetPlayerInterior(playerid,GetPlayerInterior(id));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "{FF4500}%s {FFFFFF}teleported his self to you.", name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You teleported yourself to {FF4500}%s.", PlayerName);
SendClientMessage(playerid, -1, string);
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWor ld(id));
SetPlayerPos(playerid,x+2,y,z);
SetVehiclePos(vehid,x+2,y,z);
PutPlayerInVehicle(playerid, vehid, 0);
return 1;
}
else return SendClientMessage(playerid, -1, "Usage : /goto [id/name]");
}
}
else return SendClientMessage(playerid, -1, "Player is not connected.");
}


If it's not the correct color for ORANGESV, you need to get the hex code and put it inside these brackets: {COLORCODE} so, for e.g: ****** Orange Hex Code and just get the code and do this, {FF4500}.

https://gyazo.com/ef9d76ad62345fc226bc270df7a57b2d.png

Daymen
16/07/2017, 09:57 PM
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 (c) 1997-2006, ITB CompuPhase

asri
19/07/2017, 02:21 AM
if without admin, i try before but it give a lot of error

Daymen
19/07/2017, 07:26 PM
if without admin, i try before but it give a lot of error

I don't understand what you're saying here.

What do you mean? Post the errors you're getting.

asri
22/07/2017, 11:01 AM
fix.how to make command that close/open goto command

asri
22/07/2017, 05:50 PM
how to disable/open goto command

Daymen
22/07/2017, 11:48 PM
how to disable/open goto command

I don't understand what you mean by "disable" and "open" the command?

You mean like disable it so others can't use it?

crukk11
23/07/2017, 05:57 AM
he mean when the player 1 disable goto command, player 2 cant go to player 1.

CodeStyle175
23/07/2017, 10:22 AM
#define scm SendClientMessage
#define SetPidVW SetPlayerVirtualWorld
#define GetPidVW GetPlayerVirtualWorld
#define SetPidInt SetPlayerInterior
#define GetPidInt GetPlayerInterior
#define GetVehID GetPlayerVehicleID

UName(p){
new s[24];
GetPlayerName(p,s,24);
return s;
}

cmd:goto(pid,p[]){
if(GetPVarInt(pid,"AdminLevel") < 1)return scm(pid,-1,"You are not allowed to use this command!");
if(sscanf(p,"u",id))return scm(pid,-1,"Usage : /goto [id/name]");
if(!IsPlayerConnected(id))return scm(pid,-1,"Player doesn't exsist!");
new Float:x,Float:y,Float:z,vw=GetPidVW(id),int=GetPid Int(id),vid=GetVehID(pid),s[100];
GetPlayerPos(id,x,y,z);
if(vid && GetPlayerState(pid)==PLAYER_STATE_DRIVER)SetVehicl ePos(vid,x,y,z),SetVehicleVirtualWorld(vid,vw),Lin kVehicleToInterior(vid,int);
else SetPlayerPos(pid,x,y,z);
SetPidVW(pid,GetPidVW(id)),SetPidInt(pid,GetPidInt (id));
format(s,sizeof(s),""ORANGESV"%s {FFFFFF}teleported his self to you.", UName(pid));
SendClientMessage(id,-1,s);
format(s,sizeof(s),"You teleported yourself to "ORANGESV"%s.", UName(id));
SendClientMessage(pid,-1,s);
return 1;
}

asri
29/07/2017, 07:54 AM
no i mean how to make the disable/enable goto command

Kane
29/07/2017, 08:45 AM
Do you want to disable teleporting globally or just players?

Xtra
29/07/2017, 08:48 AM
i think he wants it globally so that no one can use goto command

asri
29/07/2017, 08:52 AM
yes.

Kane
29/07/2017, 08:56 AM
#include zcmd

new bool:teleportingEnabled = true;

CMD:togtps(playerid, params[])
{
if (!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, -1, "You are not a server admin.");
// This checks if the player is an admin. If you have your own admin variable, change it there.

if (teleportingEnabled == false) // If teleporting is disabled, it turns it on.
{
teleportingEnabled = true;
SendClientMessage(playerid, -1, "You enabled teleporting. Players can use /goto now.");
}
else // Else if it's enabled, it turns it off.
{
teleportingEnabled = false;
SendClientMessage(playerid, -1, "You disabled teleporting. Players wont be able to /goto now.");
}
return true;
}

Add this to your /goto command:

if (teleportingEnabled == false)
return SendClientMessage(playerid, -1, "Teleporting is disabled right now.");

asri
29/07/2017, 09:05 AM
sorry.i want for players, not for all

Kane
29/07/2017, 09:10 AM
Do the same but make it a player variable.

new bool:teleportingEnabled[MAX_PLAYERS];

CMD:togtps(playerid, params[])
{
if(teleportingEnabled[playerid] == false){

teleportingEnabled[playerid] = true;
SendClientMessage(playerid, -1, "Players can now teleport to you.");
}
else
{
teleportingEnabled[playerid] = false;
SendClientMessage(playerid, -1, "Players can no longer teleport to you.");
}
return true;
}


Add to /goto:

if (teleportingEnabled[playerb] == false && !IsPlayerAdmin(playerid))
return SendClientMessage(playerid, -1, "This player has teleporting turned off.");

Change "playerb" to the player specifier for who you're teleporting to in the command.

asri
29/07/2017, 09:15 AM
you mean target id

Kane
29/07/2017, 09:18 AM
Yeah, whatever.

asri
29/07/2017, 09:19 AM
thank you give rep+

p.s:sorry i cannot give you because i dont have rep

JorryDagle
29/07/2017, 09:23 AM
:/ you need FS about it?.