SA-MP Forums Archive
[Tutorial] CREATING COMMAND : /get, /getall - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] CREATING COMMAND : /get, /getall (/showthread.php?tid=343925)



CREATING COMMAND : /get, /getall - ℓмяαη_кнαη - 19.05.2012

ℓмяαη_кнαη Present :

Hi all this is " ℓмяαη_кнαη " showing you on how to create some simple commands using acmd .Which is mostly used for stunting server.Hope you'll like it !!!!
1 : you'll need to download <zcmd> ****** it and then define this / add this at top of your script
pawn Code:
#include <zcmd>
pawn Code:
CMD:get(playerid, params[]) // commands /get to get player to your position
pawn Code:
{
         if (P_DATA[ playerid ][ P_Level ] < 3)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!"); // if player is admin .. You can change the max admin level < 3
pawn Code:
if (P_DATA[ playerid ][ P_Logged ] == 0)return SendError( playerid, "Please login to use this command!"); // This [P_logged ] == 0 ) 0 means that player was not login
pawn Code:
if ( sscanf( params, "u", params[ 0 ]) )return SendUsage( playerid, "/gethere <id>" ); // Showing the usage usage and using sscanf for this
pawn Code:
if ( !IsPlayerConnected( params[ 0 ] ) )return SendError( playerid, "Player is not connected!"); // invalid player
pawn Code:
if (P_DATA[ params[ 0 ] ][ P_Level ] > P_DATA[ playerid ][ P_Level ])return SendError( playerid, "You have no rights to use admin commands on higher admins!"); // change the admin elvel for up
pawn Code:
new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;
pawn Code:
if (IsPlayerInAnyVehicle( params[ 0 ] ) ) // if a player is on car the command wont work. Remove to remove this system
pawn Code:
{
        SetCameraBehindPlayer( params[ 0 ] ); // player will spawn behind the %s who get the %s player
        GetVehiclePos( GetPlayerVehicleID( playerid ), ParamVX, ParamVY, ParamVZ ); // get the %s who is going to be get
        SetVehiclePos( GetPlayerVehicleID( params[ 0 ] ), ParamVX+2, ParamVY+2, ParamVZ ); // to the person position who is getting
        LinkVehicleToInterior( GetPlayerVehicleID( params[ 0 ] ), GetPlayerInterior( playerid ));
    }
    else
    {
        SetCameraBehindPlayer( params[ 0 ] );
        GetPlayerPos( playerid, ParamX, ParamY, ParamZ );
        SetPlayerPos( params[ 0 ], ParamX+2, ParamY+2, ParamZ );
        SetPlayerInterior( params[ 0 ], GetPlayerInterior( playerid ));
    }
    FormMessageForAllEx(playerid,COLOR_GREEN, "Administrator %s teleported %s to his location!",PlayerName2( playerid ), PlayerName2( params[ 0 ] )); // send a message to all
    FormMessage( params[ 0 ], COLOR_GREEN, "Administrator %s teleported you to his position!",PlayerName2( playerid )); // send message to the player who has been getted
    FormMessage( playerid, COLOR_GREEN, "You teleported %s to your location!",PlayerName2( params[ 0 ] )); // easy to understand this one !!!!
    return 1;
} // No need to define this thing becouse its too easy and understandable
pawn Code:
CMD:getall(playerid, params[])
[PAWN]{
pawn Code:
if (P_DATA[ playerid ][ P_Level ] < 4)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!");
pawn Code:
if (P_DATA[ playerid ][ P_Logged ] == 0)return SendError( playerid, "Please login to use this command!");
    if ( sscanf( params, "s", params[ 0 ]) )return SendUsage( playerid, "/getallhere <yes>" );
pawn Code:
new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;
pawn Code:
if (strcmp( params, "yes",true) == 0)
    {
        FormMessageForAllEx(playerid,COLOR_RED, "Administrator %s has teleported everyone to his position!",PlayerName2( playerid )); // again to all
        SendClientMessage(playerid,COLOR_GREEN, "You have teleported everyone to your position everyone!");
        new string[256];
        GetPlayerPos( playerid,Float:ParamX, Float:ParamY, Float:ParamZ);
        GetVehiclePos( GetPlayerVehicleID( playerid ), ParamVX, ParamVY, ParamVZ );
        foreach(Player, x){
            if(P_DATA[ x ][ P_Level ] < 4 ){ // you can change the max admin level 3
                if( x != playerid ){
                    if (IsPlayerInAnyVehicle( x ) )
                    {
                        SetCameraBehindPlayer( x );
                        SetVehiclePos( GetPlayerVehicleID( x ), ParamVX+2, ParamVY+2, ParamVZ );
                        LinkVehicleToInterior( GetPlayerVehicleID( x ), GetPlayerInterior( playerid ));
                    }
                    else
                    {
                        SetCameraBehindPlayer( x );
                        SetPlayerPos( x, ParamX+2, ParamY+2, ParamZ );
                        SetPlayerInterior( x, GetPlayerInterior( playerid ));
                    }
                    format(string, sizeof( string ), "Administrator %s teleported everyone to his position!",PlayerName2( playerid ));
                    SendClientMessage(x, COLOR_GREEN, string);
                }

            }
        }
    }
    else SendUsage( playerid, "/getall <yes>" );
    return 1;
}
Full Code here :

pawn Code:
CMD:get(playerid, params[]) // commands /get to get player to your position
{
    if (P_DATA[ playerid ][ P_Level ] < 3)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!"); // if player is admin .. and the level define here
    if (P_DATA[ playerid ][ P_Logged ] == 0)return SendError( playerid, "Please login to use this command!"); // Player is admin but not login ...
    if ( sscanf( params, "u", params[ 0 ]) )return SendUsage( playerid, "/gethere <id>" ); // usage and using sscanf for this
    if ( !IsPlayerConnected( params[ 0 ] ) )return SendError( playerid, "Player is not connected!"); // invalid player
    if (P_DATA[ params[ 0 ] ][ P_Level ] > P_DATA[ playerid ][ P_Level ])return SendError( playerid, "You have no rights to use admin commands on higher admins!");
    new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;

    if (IsPlayerInAnyVehicle( params[ 0 ] ) ) // if a player is on car the command wont work. Remove to remove this system
    {
        SetCameraBehindPlayer( params[ 0 ] ); // player will spawn behind the %s who get the %s player
        GetVehiclePos( GetPlayerVehicleID( playerid ), ParamVX, ParamVY, ParamVZ ); // get the %s who is going to be get
        SetVehiclePos( GetPlayerVehicleID( params[ 0 ] ), ParamVX+2, ParamVY+2, ParamVZ ); // to the person position who is getting
        LinkVehicleToInterior( GetPlayerVehicleID( params[ 0 ] ), GetPlayerInterior( playerid ));
    }
    else
    {
        SetCameraBehindPlayer( params[ 0 ] );
        GetPlayerPos( playerid, ParamX, ParamY, ParamZ );
        SetPlayerPos( params[ 0 ], ParamX+2, ParamY+2, ParamZ );
        SetPlayerInterior( params[ 0 ], GetPlayerInterior( playerid ));
    }
    FormMessageForAllEx(playerid,COLOR_GREEN, "Administrator %s teleported %s to his location!",PlayerName2( playerid ), PlayerName2( params[ 0 ] ));
    FormMessage( params[ 0 ], COLOR_GREEN, "Administrator %s teleported you to his position!",PlayerName2( playerid ));
    FormMessage( playerid, COLOR_GREEN, "You teleported %s to your location!",PlayerName2( params[ 0 ] )); // easy to understand this one !!!!
    return 1;
}

CMD:getall(playerid, params[])
{
    if (P_DATA[ playerid ][ P_Level ] < 4)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!");
    if (P_DATA[ playerid ][ P_Logged ] == 0)return SendError( playerid, "Please login to use this command!");
    if ( sscanf( params, "s", params[ 0 ]) )return SendUsage( playerid, "/getallhere <yes>" );

    new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;

    if (strcmp( params, "yes",true) == 0)
    {
        FormMessageForAllEx(playerid,COLOR_RED, "Administrator %s has teleported everyone to his position!",PlayerName2( playerid ));
        SendClientMessage(playerid,COLOR_GREEN, "You have teleported everyone to your position everyone!");
        new string[256];
        GetPlayerPos( playerid,Float:ParamX, Float:ParamY, Float:ParamZ);
        GetVehiclePos( GetPlayerVehicleID( playerid ), ParamVX, ParamVY, ParamVZ );
        foreach(Player, x){
            if(P_DATA[ x ][ P_Level ] < 4 ){
                if( x != playerid ){
                    if (IsPlayerInAnyVehicle( x ) )
                    {
                        SetCameraBehindPlayer( x );
                        SetVehiclePos( GetPlayerVehicleID( x ), ParamVX+2, ParamVY+2, ParamVZ );
                        LinkVehicleToInterior( GetPlayerVehicleID( x ), GetPlayerInterior( playerid ));
                    }
                    else
                    {
                        SetCameraBehindPlayer( x );
                        SetPlayerPos( x, ParamX+2, ParamY+2, ParamZ );
                        SetPlayerInterior( x, GetPlayerInterior( playerid ));
                    }
                    format(string, sizeof( string ), "Administrator %s teleported everyone to his position!",PlayerName2( playerid ));
                    SendClientMessage(x, COLOR_GREEN, string);
                }

            }
        }
    }
    else SendUsage( playerid, "/getall <yes>" );
    return 1;
}
Give me reputation if this is useful .


Re: CREATING COMMAND : /get, /getall - JAMMIEISFTW - 19.05.2012

Some typing errors/ spelling mistakes need checking.


Re: CREATING COMMAND : /get, /getall - JaKe Elite - 19.05.2012

i will rep you (Not) for this


Re: CREATING COMMAND : /get, /getall - ℓмяαη_кнαη - 19.05.2012

Quote:
Originally Posted by Romel
View Post
i will rep you (Not) for this
Any way thanks for feedback :

Quote:
Originally Posted by JAMMIEISFTW
View Post
Some typing errors/ spelling mistakes need checking.
thanks but i dont have enough time :P


Re: CREATING COMMAND : /get, /getall - newbienoob - 19.05.2012

You need to explain everything in your tutorial!

pawn Code:
if (P_DATA[ playerid ][ P_Level ] < 3)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!");
We will get undefined symbol... blablabla


Re: CREATING COMMAND : /get, /getall - ℓмяαη_кнαη - 19.05.2012

Quote:
Originally Posted by newbienoob
View Post
You need to explain everything in your tutorial!

pawn Code:
if (P_DATA[ playerid ][ P_Level ] < 3)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!");
We will get undefined symbol... blablabla
Already explained
Quote:
Originally Posted by ℓмяαη_кнαη
View Post
  • Now cmd is created now we will define that IsPlayerAdmin . Mean only administrator's of server can use this command !!!!
pawn Code:
{
         if (P_DATA[ playerid ][ P_Level ] < 3)return SendError( playerid, "You are not allowed to use this command"),SendReason( playerid, " Low level!"); // if player is admin .. You can change the max admin level < 3