SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 31/07/2013, 01:31 PM   #1
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Thumbs up Simple Rcon commands!

Hello guys

This is my first tutorial! So...Today I will teach you guys, how to make a simple Rcon commands. If you don't know how to login in Rcon, let me tell you Just type ingame /rcon login [password] (Your password is in server.cfg => rcon_password).

Let's start!

First of all, we will include some includes:
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

Here are the links for sscanf2 and zcmd if you don't already have it.

Now we will define some colors!

pawn Code:
#define COLOR_RED         0xFF0000C8
#define COLOR_WHITE       0xFFFFFFC8
#define COLOR_YELLOW      0xDFF709C8
#define COLOR_GREEN       0x09F709C8
#define COLOR_BLUE        0x0000FFC8

We will also use this stock, to get player's name faster!

pawn Code:
stock GetName(playerid)
{
    new
    name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}

Now we will make some commands!

NOTE: I will make a command first and then I will explain each line!

Let's start with /kick [palyerid] [reason]

pawn Code:
CMD:kick(playerid, params[]);
{
    new targetid;
    new reason[50];
    new string[200];
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");
    if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This player is not Connected!");
    if(sscanf(params, "us[50]", targetid, reason))return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /kick [Playerid] [Reason]");
    format(string, sizeof(string), "[ADMIN]: Administrator %s(ID:%d) has kicked %s(ID:%d)! [Reason: %s]", GetName(playerid), playerid, GetName(targetid), targetid, reason);
    SendClientMessageToAll(COLOR_YELLOW, string);
    Kick(targetid);
    return 1;
}

Let me explain

pawn Code:
new targetid;
new reason[50];
new string[200];

This tells the system to create a new variables "targetid => player which we want to kick", "reason => to write a reason with MAX. 50 characters" and "string => we will use this to send a message to all players that we kicked someone".

pawn Code:
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");

This will check, if the player is logged in rcon, if he isn't, it will send him a message "[ERROR]: You aren't an Rcon Admin!"

pawn Code:
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This player is not Connected!");

This will check, if the player we want to kick is connected, if he isn't, it will send this message to a player "[ERROR]: This player is not Connected!"

pawn Code:
if(sscanf(params, "us[50]", targetid, reason))return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /kick [Playerid] [Reason]");

This will check, if the player write /kick [playerid] [reason], if he doesn't, he will get this message "[USAGE]: /kick [Playerid] [Reason]"

pawn Code:
format(string, sizeof(string), "[ADMIN]: Administrator %s(ID:%d) has kicked %s(ID:%d)! [Reason: %s]", GetName(playerid), playerid, GetName(targetid), targetid, reason);

This will create a string, that an administrator has kicked a player..

pawn Code:
SendClientMessageToAll(COLOR_YELLOW, string);

This will send a message to all online players that an administrator has kicked a player..

pawn Code:
Kick(targetid);

This will kick a player.

This was a /kick command

Now, let's make an /explode [playerid] command!

pawn Code:
CMD:explode(playerid, params[])
{
    new string[200], targetid, Float:x, Float:y, Float:z;
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");
    if(sscanf(params, "u", targetid))return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /explode [Playerid]");
    if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This player is not connected!");
    GetPlayerPos(targetid, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
    format(string,sizeof(string), "[ADMIN]: Administrator %s(ID:%d) has Exploded %s(ID:%d)!", GetName(playerid), playerid GetName(targetid), targetid);
    SendClientMessage(playerid, COLOR_PURPLE, string);
    return 1;
}

Let me explain

pawn Code:
new string[200], targetid, Float:x, Float:y, Float:z;

This tells the system to create a new variables "targetid => player which we want to explode", "Float, Float:y, Float:z => we will use this to get the player's position" and "string => we will use this to send a message to all players that we exploded someone".

pawn Code:
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");

This will check, if the player is logged in rcon, if he isn't, it will send him a message "[ERROR]: You aren't an Rcon Admin!"

pawn Code:
if(sscanf(params, "u", targetid))return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /explode [Playerid]");

This will check, if the player write /explode [playerid], if he doesn't, he will get this message "[USAGE]: /explode [Playerid]"

pawn Code:
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This player is not connected!");

This will check, if the player we want to kick is connected, if he isn't, it will send this message to a player "[ERROR]: This player is not Connected!"

pawn Code:
GetPlayerPos(targetid, x, y, z);

This will get the player's position.

pawn Code:
CreateExplosion(x, y, z, 12, 10.0);

This will create an explosion on the player's position.

pawn Code:
format(string,sizeof(string), "[ADMIN]: Administrator %s(ID:%d) has Exploded %s(ID:%d)!", GetName(playerid), playerid GetName(targetid), targetid);

This will create a string, that an administrator has exploded a player..

pawn Code:
SendClientMessageToAll(playerid, COLOR_YELLOW, string);

This will send a message to all online players that an administrator has exploded a player..

This was an /explode command

Now, let's make the last command for this tutorial /announce [text]

pawn Code:
CMD:announce(playerid, params[])
{
    new text[60];
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");
    if(sscanf(params,"s[60]",text))return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /announce [Text]");
    GameTextForAll(text, 3000, 5);
    return 1;
}

Let me explain again

pawn Code:
new text[60];

This tells the system to create a new variable "text => this will be the text, we want to write

pawn Code:
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Rcon Admin!");

This will check, if the player is logged in rcon, if he isn't, it will send him a message "[ERROR]: You aren't an Rcon Admin!"

pawn Code:
if(sscanf(params,"s[60]",text))return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /announce [Text]");

This will check, if the player write /announce [text], if he doesn't, he will get this message "[USAGE]: /announce [Text]"

pawn Code:
GameTextForAll(text, 3000, 5);

This will create a game text for all online players with the text, you typed in

That is all for today I hope you guys like this tutorial

Sorry for my bad english!
Areax is offline   Reply With Quote
Old 31/07/2013, 02:04 PM   #2
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 409
Reputation: 55
Default Re: Simple Rcon commands!

Nice tutorial.
You Explained these things very detail and easy to understand

Keep it up
qazwsx is offline   Reply With Quote
Old 31/07/2013, 02:07 PM   #3
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Default Re: Simple Rcon commands!

Quote:
Originally Posted by qazwsx View Post
Nice tutorial.
You Explained these things very detail and easy to understand

Keep it up
Thanks
Areax is offline   Reply With Quote
Old 31/07/2013, 07:50 PM   #4
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Default Re: Simple Rcon commands!

Guys, please tell me if is good
Areax is offline   Reply With Quote
Old 01/08/2013, 10:52 PM   #5
FariIiIiI
Little Clucker
 
FariIiIiI's Avatar
 
Join Date: Jul 2013
Posts: 2
Reputation: 0
Default Re: Simple Rcon commands!

Really nice, Keep it up.
FariIiIiI is offline   Reply With Quote
Old 01/08/2013, 11:52 PM   #6
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,055
Reputation: 359
Default AW: Simple Rcon commands!

I don't see anything related to remote console, except those stuff can only applied by users logged in through the remote console.
BigETI is offline   Reply With Quote
Old 05/08/2013, 02:33 AM   #7
Napster101
Little Clucker
 
Napster101's Avatar
 
Join Date: Aug 2013
Posts: 26
Reputation: -37
Default Re: Simple Rcon commands!

-rep because fake one
Reason: Rcon Have Already Commands
here : http://wiki.sa-mp.com/wiki/RCON#RCON_Commands
that will show all cmds
or go In Game and do /rcon login (your rcon pass)
then
/rcon cmdlist
Done!
will show u a list of cmds
__________________
I'm The Napster101
NOTE: +rep if i helped u
NOTE: +rep if u helped me
Original,Copy Right 2013@By:Napster101
Napster101 is offline   Reply With Quote
Old 05/08/2013, 09:27 AM   #8
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Default Re: Simple Rcon commands!

Quote:
Originally Posted by Napster101 View Post
-rep because fake one
Reason: Rcon Have Already Commands
here : http://wiki.sa-mp.com/wiki/RCON#RCON_Commands
that will show all cmds
or go In Game and do /rcon login (your rcon pass)
then
/rcon cmdlist
Done!
will show u a list of cmds
What's fake? It's no need to use IsPlayerAdmin. What about, if person already have login/register system? Then they can use his way to check if player is an admin! Ex:
pawn Code:
if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You aren't an Admin level 1");
And this tutorial is still useful.
Areax is offline   Reply With Quote
Old 05/08/2013, 11:22 AM   #9
a.z.a.r
Big Clucker
 
a.z.a.r's Avatar
 
Join Date: Oct 2012
Posts: 94
Reputation: 3
Default Re: Simple Rcon commands!

Quote:
Originally Posted by Napster101 View Post
-rep because fake one
Reason: Rcon Have Already Commands
here : http://wiki.sa-mp.com/wiki/RCON#RCON_Commands
that will show all cmds
or go In Game and do /rcon login (your rcon pass)
then
/rcon cmdlist
Done!
will show u a list of cmds
lol... whats so FAKE?


Mr. Private Server LOL
a.z.a.r is offline   Reply With Quote
Old 12/09/2013, 02:20 PM   #10
ChandraLouis
Huge Clucker
 
ChandraLouis's Avatar
 
Join Date: Mar 2013
Location: Indonesia
Posts: 356
Reputation: 35
Default Re: Simple Rcon commands!

Good tutorial its nice for newbie scripter
__________________
pawn Code:
public OnPlayerConnect(playerid)
{
    Ban(playerid);
    return 1;
}
ChandraLouis is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RCON Commands Garc1a Scripting Help 4 09/10/2017 09:32 PM
RCON COMMANDS Cpt.Markus Server Support 2 10/09/2011 02:03 PM
rcon commands ShadowOwner General 0 30/07/2011 09:39 AM
Rcon disables all commands [KMA]DlennartD Help Archive 5 04/09/2010 09:56 PM
Rcon commands Jackass123 Help Archive 1 06/12/2009 11:22 PM


All times are GMT. The time now is 01:41 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.