SA-MP Forums Archive
Command Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command Help (/showthread.php?tid=291799)



Command Help - Kostas' - 21.10.2011

I have a made a /goto command, but when I /goto 2 (id 2 = Me), it doesn't says You cannot goto yourself, and teleport to myself.
It appears Kostas has teleported you!
Also, The !IsPlayerConnected doesn't work and teleport underground at the farm. And it appears "You have teleport (id)"
pawn Код:
if ( strcmp( cmd, "/goto", true ) == 0 ) {
        new pID = strval(cmdtext);
        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, "This player has disable teleport");
        else {
            new tmp[256];
            tmp = strtok( cmdtext, idx );
            if ( !strlen( tmp ) ) { return 1; }
            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 have teleported to %s(%d)", Pname, strval(tmp));
            SendClientMessage(playerid, COLOR_ORANGE, String);
            GetPlayerName(playerid, Pname, sizeof(Pname));
            format(String, sizeof(String), "{FF9600}%s(%d) has teleported to your location", Pname, playerid);
            SendClientMessage(strval(tmp), COLOR_ORANGE, String);
        }
        return 1;
    }



Re: Command Help - aRoach - 21.10.2011

pawn Код:
if ( strcmp( cmd, "/goto", true ) == 0 )
{
    new pID = strval(cmdtext);
    if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");
    if(AllowGoto[pID] == 0) return SendClientMessage(playerid, COLOR_RED, "This player has disable teleport");
    if( pID == playerid ) return SendClientMessage(playerid, COLOR_RED, "You cannot goto yourself");
    if( !IsPlayerConnected( pID ) && pID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_RED, "Player is not connected!" );

    new tmp[256];
    tmp = strtok( cmdtext, idx );
    if ( !strlen( tmp ) ) { return 1; }
    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 have teleported to %s(%d)", Pname, strval(tmp));
    SendClientMessage(playerid, COLOR_ORANGE, String);
    GetPlayerName(playerid, Pname, sizeof(Pname));
    format(String, sizeof(String), "{FF9600}%s(%d) has teleported to your location", Pname, playerid);
    SendClientMessage(strval(tmp), COLOR_ORANGE, String);

    return 1;
}



Re: Command Help - Kostas' - 21.10.2011

Quote:
Originally Posted by aRoach
Посмотреть сообщение
pawn Код:
if ( strcmp( cmd, "/goto", true ) == 0 )
{
    new pID = strval(cmdtext);
    if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");
    if(AllowGoto[pID] == 0) return SendClientMessage(playerid, COLOR_RED, "This player has disable teleport");
    if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot goto yourself");
    if( pID == INVALID_PLAYER_ID || !IsPlayerConnected( pID ) ) return SendClientMessage( playerid, COLOR_RED, "Player is not connected!" );
    else
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if ( !strlen( tmp ) ) { return 1; }
        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 have teleported to %s(%d)", Pname, strval(tmp));
        SendClientMessage(playerid, COLOR_ORANGE, String);
        GetPlayerName(playerid, Pname, sizeof(Pname));
        format(String, sizeof(String), "{FF9600}%s(%d) has teleported to your location", Pname, playerid);
        SendClientMessage(strval(tmp), COLOR_ORANGE, String);
    }
    return 1;
}
Still nothing. I can teleport to myself and I still when I teleport to a player that isn't connected i fall underground at the farm.


Re: Command Help - TouR - 21.10.2011

Do you use 0.3d?


Re: Command Help - Kostas' - 21.10.2011

Nop, I use 0.3c R5


Re: Command Help - [MWR]Blood - 21.10.2011

pawn Код:
new pID = strval(cmdtext);
to
pawn Код:
new pID = strval(tmp);



Re: Command Help - aRoach - 21.10.2011

pawn Код:
if ( strcmp( cmd, "/goto", true ) == 0 )
{
    new pID = strval(tmp);
    if(!strlen(cmdtext)) return SendClientMessage(playerid, 0xFF0000AA, "/Goto [playerid]");
    if(AllowGoto[pID] == 0) return SendClientMessage(playerid, COLOR_RED, "This player has disable teleport");
    if( pID == playerid ) return SendClientMessage(playerid, COLOR_RED, "You cannot goto yourself");
    if( !IsPlayerConnected( pID ) && pID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_RED, "Player is not connected!" );

    new tmp[256];
    tmp = strtok( cmdtext, idx );
    if ( !strlen( tmp ) ) { return 1; }
    new Float:X, Float:Y, Float:Z, Pname[24];
    GetPlayerPos( pID, 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(pID, Pname, sizeof(Pname));
    format(String, sizeof(String), "{FF9600}You have teleported to %s(%d)", Pname, pID);
    SendClientMessage(playerid, COLOR_ORANGE, String);
    GetPlayerName(playerid, Pname, sizeof(Pname));
    format(String, sizeof(String), "{FF9600}%s(%d) has teleported to your location", Pname, playerid);
    SendClientMessage(pID, COLOR_ORANGE, String);

    return 1;
}
Try this...


Re: Command Help - Kostas' - 21.10.2011

Thank you!