07.08.2015, 22:12
Admin Slap Command
Hello everyone, I'm new on this forum so I decided to clarify things a little bit about the Slap Command!
So enough talk, we will start to work! Just follow me and everything will be fine!
Firstly we have to download one include! Name of Include: ZCMD
You can download ZCMD from this link: http://www.solidfiles.com/d/d20f/
How to install ZCMD? - First, when you download it you have to insert it into: YourServer/pawno/include
When you do that you have to Include ZCMD in your GameMode Script or FilterScript!
So we will then need to download one include and at the same time plugin!
Of course it is a SSCANF!
You can find Informations about SSCANF here: https://sampforum.blast.hk/showthread.php?tid=570927
Now You need to include a SSCANF in your script:
When you do this we are going to write the command for Slap!
We'll do it this way, just follow me:
All right, Now I will make one condition for that command!
Warning: If you have made the base, where it is stored admin level, you can place it with your script, but I will use Rcon Admin!
All right, I'm a little speed things up, but now I will explain the condition!
When a player type that command in my way "slap", first what the script do, it will will check whether the player is logged as RCON! If player is logged as RCON Admin, command will work , if not display a message: "You are not authorized to use this command!"
All right, I'm going to show you next step:
First we make new features which we have not yet given function!
So let's give them the functions!
All right, Now I'll explain in a bit!
First Line: If player type command /slap (not id) or only /slap it will display a message Usage: /slap [id]!
Second Line: If player type invalid id, it will display message Player is not connected any more!
Now make a function of command /slap!
Just follow my step!
Now we will explain code!
If admin successfully typed /slap command do this:
First Line: It will display message to you! You have been successful ...
Second Line: It will get position of target!
Third Line: It will change position of target for +4 Degress in height
Fourth Line: It will get name of admin!
Fifth Line: It will format a message!
Sixth Line:: It will send message to player "You have been slapped..."!
And of course full code is:
If you do not understand something, do not jump, read and concentrate, can not skip it!
This is a very simple command, and I hope that you will quickly understand!
If you like this Tutorial Please R+!
Hello everyone, I'm new on this forum so I decided to clarify things a little bit about the Slap Command!
So enough talk, we will start to work! Just follow me and everything will be fine!
Firstly we have to download one include! Name of Include: ZCMD
You can download ZCMD from this link: http://www.solidfiles.com/d/d20f/
How to install ZCMD? - First, when you download it you have to insert it into: YourServer/pawno/include
When you do that you have to Include ZCMD in your GameMode Script or FilterScript!
Код:
include <zcmd>
Of course it is a SSCANF!
You can find Informations about SSCANF here: https://sampforum.blast.hk/showthread.php?tid=570927
Now You need to include a SSCANF in your script:
Код:
#include <sscanf> // if you have sscanf version 1 #include <sscanf2> // if you have sscanf version 2 #include <sscanf3> // if you have sscanf version 3
We'll do it this way, just follow me:
Код:
CMD:slap(playerid, params[]) { // here is function return 1; }
Код:
CMD:slap(playerid, params[]) { if(IsPlayerAdmin(playerid)) { //if player admin } else { //if player not admin SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!"); } return 1; }
All right, I'm a little speed things up, but now I will explain the condition!
When a player type that command in my way "slap", first what the script do, it will will check whether the player is logged as RCON! If player is logged as RCON Admin, command will work , if not display a message: "You are not authorized to use this command!"
All right, I'm going to show you next step:
Код:
new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128];
So let's give them the functions!
Код:
if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"Usage: /slap [id]"); else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
First Line: If player type command /slap (not id) or only /slap it will display a message Usage: /slap [id]!
Second Line: If player type invalid id, it will display message Player is not connected any more!
Now make a function of command /slap!
Just follow my step!
Код:
else { SendClientMessage(playerid,-1,"You have been successful slapped that player!"); // message to you GetPlayerPos(id,x,y,z); // Get Position of Target SetPlayerPos(id,x,y,z+4); // Change position of target for +4 Degrees in height GetPlayerName(playerid,name,sizeof(name)); // Get Player name format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s",name); // Format Message SendClientMessage(id,-1,msg); // send message to player }
If admin successfully typed /slap command do this:
First Line: It will display message to you! You have been successful ...
Second Line: It will get position of target!
Third Line: It will change position of target for +4 Degress in height
Fourth Line: It will get name of admin!
Fifth Line: It will format a message!
Sixth Line:: It will send message to player "You have been slapped..."!
And of course full code is:
Код:
CMD:slap(playerid, params[]) { if(IsPlayerAdmin(playerid)) { //if player admin new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128]; if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"Usage: /slap [id]"); else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!"); else { SendClientMessage(playerid,-1,"You have been successful slapped that player!"); // message to you GetPlayerPos(id,x,y,z); // Get Position of Target SetPlayerPos(id,x,y,z+4); // Change position of target for +4 Degrees in height GetPlayerName(playerid,name,sizeof(name)); // Get Player name format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s",name); // Format Message SendClientMessage(id,-1,msg); // send message to player } } else { //if player not admin SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!"); } return 1; }
If you do not understand something, do not jump, read and concentrate, can not skip it!
This is a very simple command, and I hope that you will quickly understand!
If you like this Tutorial Please R+!