[Tutorial] CREATING COMMAND : /get, /getall
#1

ℓмяαη_кнαη 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>
  • OOK We will create the command
pawn Code:
CMD:get(playerid, params[]) // commands /get to get player to your position
  • Now cmd is created now we wiull 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
  • Now We will tell the system to not to allowed the %s player if he was not logined !!!
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
  • Now to send the Specific player the correct usege of commands !!!!
pawn Code:
if ( sscanf( params, "u", params[ 0 ]) )return SendUsage( playerid, "/gethere <id>" ); // Showing the usage usage and using sscanf for this
  • To use the correct mean is the player connected >? We'll use
pawn Code:
if ( !IsPlayerConnected( params[ 0 ] ) )return SendError( playerid, "Player is not connected!"); // invalid player
  • If the player was not enoughed leveled mean he was not administrator . we will use !!!
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
  • Now we will use this function paramsX to get the %s and %s position :
pawn Code:
new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;
  • Remember : we will use " IsPlayerInAnyVehicle " which used for if a player is in any cars .This system wont get the %s player
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
  • Again to create the command to getall player in your position:
pawn Code:
CMD:getall(playerid, params[])
  • Again the same to not to allow the player to use this command if he is not enought leveld .So we will use
[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!");
  • We will use this if a player is not login .%s player whos is trying to use this command
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>" );
  • To get all player position and gather them
pawn Code:
new Float:ParamX, Float:ParamY, Float:ParamZ, Float:ParamVX, Float:ParamVY, Float:ParamVZ;
  • Once the player is logined and admin levled so we will make it
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 .
Reply
#2

Some typing errors/ spelling mistakes need checking.
Reply
#3

i will rep you (Not) for this
Reply
#4

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
Reply
#5

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
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)