Command /goto /nogoto
#1

Hello,
For several days looking /goto /nogoto command can teleport with NICK and ID.
I found this code on this site:
Код:
if ( strcmp( cmd, "/goto", true ) == 0 ) {
        
        tmp = strtok( cmdtext, idx );
        if ( !strlen( tmp ) ) { return 1; }
        new pID = strval(tmp);
        if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");
        else if( pID == INVALID_PLAYER_ID || !IsPlayerConnected( pID ) ) return SendClientMessage( playerid, COLOR_RED, "Player is not connected!" );
        else if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot goto yourself");
        else if(AllowGoto[pID] == 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player has prevent teleporting to them");
        else {
            new Float:X, Float:Y, Float:Z, Pname[24];
            GetPlayerPos( strval(tmp), X, Y, Z );
            ResetPlayerWeapons(playerid);
            if (GetPlayerState(playerid)==PLAYER_STATE_DRIVER)SetVehiclePos( GetPlayerVehicleID(playerid), X+2, Y+2, Z );
            else SetPlayerPos( playerid, X+2, Y+2, Z );
            new String[56];
            GetPlayerName(strval(tmp), Pname, sizeof(Pname));
            format(String, sizeof(String), "{FF9600}You teleported to %s.", Pname, strval(tmp));
            SendClientMessage(playerid, COLOR_ORANGE, String);
            GetPlayerName(playerid, Pname, sizeof(Pname));
            format(String, sizeof(String), "{FF9600}%s has teleported to your location, type /tgoto to disable this in the future!", Pname, playerid);
            SendClientMessage(strval(tmp), COLOR_ORANGE, String);
        }
        return 1;
    }
    if(strcmp(cmdtext, "/toggoto", true) == 0)
	{
	    if(AllowGoto[playerid] == 0)
	    {
	        AllowGoto[playerid] = 1;
	        SendClientMessage(playerid, -1, "Other players may not teleport to you now!");
	    }
	    else if(AllowGoto[playerid] == 1)
	    {
	        AllowGoto[playerid] = 0;
	        SendClientMessage(playerid, -1, "Other players may teleport to you now!");
	    }
	    return 1;
	}
When testing this code I found the following.
ID 0 is unable to teleport to Nick (Only with ID)
ID 1 can teleport with username + ID
And when you get into a server in another 2 persons / goto NICK confused nickname and teleport at ID 0.

Can anyone help fix this problem?
Or give me a working code to be able to teleport a Username and ID and work / nogoto

Server client is 0.3z
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)