SA-MP Forums Archive
2 in 1 commands - 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: 2 in 1 commands (/showthread.php?tid=354110)



2 in 1 commands - kbalor - 25.06.2012

If player type /go <id> the player teleports to another player, when he type /go again without <id> player can't be teleported or lets say he can disable and enable goes by typing /go again.


Re: 2 in 1 commands - dowster - 25.06.2012

In the area where you execute the command, add in a check to see if the parameter was entered. What command processor are you using?


Re: 2 in 1 commands - kbalor - 25.06.2012

Quote:
Originally Posted by dowster
Посмотреть сообщение
In the area where you execute the command, add in a check to see if the parameter was entered. What command processor are you using?
I know this command is possible to do but i dont know how to start, Im using ZCMD.


Re: 2 in 1 commands - FalconX - 25.06.2012

pawn Код:
new bool:bIsGoEnabled[ MAX_PLAYERS ]; // top


CMD:go( playerid, params[ ] )
{
    if( isnull( params ) )
    {
        if( bIsGoEnabled[ playerid ] )
        {
            bIsGoEnabled[ playerid ] = false;
            SendClientMessage( playerid, -1, "GO: Disabled" );
        }
        else
        {
            bIsGoEnabled[ playerid ] = true;
            SendClientMessage( playerid, -1, "GO: Enabled" );
        }
    }
    else
    {
        new goid;
        if( sscanf( params, "u", goid ) ) return SendClientMessage( playerid, -1, "Error: /go <id>" );
        if( IsPlayerConnected( goid ) || goid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Error: Player not connected or invalid id" );
       
        if( !bIsGoEnabled[ playerid ] ) return SendClientMessage( playerid, -1, "Error: GO is disabled." );
       
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos( goid, X, Y, Z );
        SetPlayerPos( playerid, X, Y, Z );
       
        SendClientMessage( playerid, -1, "GO: You have been teleported." );
    }
    return 1;
}
Not sure if this is what you want, just made it as soon as I could - Try and see I am unsure if it has bugs or something..

Hope this helps.
Regards,
FalconX


Re: 2 in 1 commands - kbalor - 25.06.2012

Quote:
Originally Posted by FalconX
Посмотреть сообщение
pawn Код:
new bool:bIsGoEnabled[ MAX_PLAYERS ]; // top


CMD:go( playerid, params[ ] )
{
    if( isnull( params ) )
    {
        if( bIsGoEnabled[ playerid ] )
        {
            bIsGoEnabled[ playerid ] = false;
            SendClientMessage( playerid, -1, "GO: Disabled" );
        }
        else
        {
            bIsGoEnabled[ playerid ] = true;
            SendClientMessage( playerid, -1, "GO: Enabled" );
        }
    }
    else
    {
        new goid;
        if( sscanf( params, "u", goid ) ) return SendClientMessage( playerid, -1, "Error: /go <id>" );
        if( IsPlayerConnected( goid ) || goid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Error: Player not connected or invalid id" );
       
        if( !bIsGoEnabled[ playerid ] ) return SendClientMessage( playerid, -1, "Error: GO is disabled." );
       
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos( goid, X, Y, Z );
        SetPlayerPos( playerid, X, Y, Z );
       
        SendClientMessage( playerid, -1, "GO: You have been teleported." );
    }
    return 1;
}
Not sure if this is what you want, just made it as soon as I could - Try and see I am unsure if it has bugs or something..

Hope this helps.
Regards,
FalconX
Nothings change bro nothing happens. Can you make it simple script? If

/go - sendclientmessage /go <id>
/gof - Disable goes.

also add if player is not online - Player not connected or invalid id


Re: 2 in 1 commands - FalconX - 13.07.2012

pawn Код:
new bool:bIsGoEnabled; // top


CMD:go( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You have to be an admin to enable/disable go" );
   
    new goid;
    if( sscanf( params, "u", goid ) )
    {
        if( bIsGoEnabled )
        {
            bIsGoEnabled = false;
            SendClientMessage( playerid, -1, "GO: Disabled" );
        }
        else
        {
            bIsGoEnabled = true;
            SendClientMessage( playerid, -1, "GO: Enabled" );
        }
    }
    else
    {
        if( IsPlayerConnected( goid ) || goid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Error: Player not connected or invalid id" );

        if( !bIsGoEnabled ) return SendClientMessage( playerid, -1, "Error: GO is disabled." );

        new Float:X, Float:Y, Float:Z;
        GetPlayerPos( goid, X, Y, Z );
        SetPlayerPos( playerid, X, Y, Z );

        SendClientMessage( playerid, -1, "GO: You have been teleported." );
    }
    return 1;
}
Sorry for a big bump - I've been away from SA-MP forums from few days but I thought to help you out if you are still active here.

Regards,
FalconX