11.12.2012, 12:37
(
Последний раз редактировалось ZackBoolaro; 11.12.2012 в 17:05.
)
What is this tutorial about ?:
Hello everyone today ill teach you how to make a simple command that is going to replace your current car rims with "Switch" ones.
The tutorial:
Okay so, the includes and plugins that you are gonna need for this tutorial are:
ZCMD(Include), SSCANF(Include and Plugin); You can get them from here(sscanf) and here(zcmd).
Okay so lets get started, the first thing you have to do is include the "include" files into your script, we are gonna do that with:
You have to place the code above, just below the "#include <a_samp>" like that:
The second thing we need to do is to define a color that we are gonna use for the message that we are gonna send to the player after a successful rims change. I'm gonna use a light red color for this message.
You have to place the code above, just below the "#includes" like that:
The third thing we have to do is go wherever in the script you want(it must be below the "includes" and "defines"), then we are gonna start making command:
Hello everyone today ill teach you how to make a simple command that is going to replace your current car rims with "Switch" ones.
The tutorial:
Okay so, the includes and plugins that you are gonna need for this tutorial are:
ZCMD(Include), SSCANF(Include and Plugin); You can get them from here(sscanf) and here(zcmd).
Okay so lets get started, the first thing you have to do is include the "include" files into your script, we are gonna do that with:
pawn Код:
#include <zcmd> and #include <sscanf2>
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
pawn Код:
#define COLOR_LIGHTRED 0xFF99AADD
pawn Код:
#include <a_samp> //This is the main include, it comes with each script, without this include you can't do anything in the script.
#include <zcmd> //This will include the ZCMD processor into the script so we can use all of it's futures.
#include <sscanf2> //This will include SSCANF into the script so we can use all of it's futures.
#define COLOR_LIGHTRED 0xFF99AADD //This will make so you don't have to memorise all this 0xFF99AADD whenever you want to use the color, you just type COLOR_LIGHTRED
pawn Код:
//I guess you want to restrict this cmd only to admins so I'm gonna implement a little admin check
CMD:gr(playerid, params[]) //Here we are telling the script that this is a command made with zcmd you are not suposed to put those commands under "OnPlayerCommandText" callback, the "params" are the parameters you are gonna type in /gr [params/carid] in our case is the car id.
{
if(IsPlayerAdmin(playerid)){
new carid; //Firstly we are making a new variable that is going to hold the vehicle id.
if(sscanf(params, "d", carid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gr [carid]");// This just checks if the parameters(the carid) are not typed, it will pop that message.
AddVehicleComponent(carid, 1080); //This is the actual function that's gonna change our rims to "gold" ones. You may ask why there is not a static id on the "AddVehicleComponent(carid, 1080);" and we are using the variable we created above ? Well, in order to change the rims of the car id you typed into the command you have to place the "carid" variable instead of static id. Because no matter what id you type into the cmd if you have a static id onto the "AddVehicleComponent" function, it will not change the rims of the carid you typed it will chage the rims of the carid you've typed instead of "carid" variable.
SendClientMessage(playerid, COLOR_LIGHTRED, "Success"); //We are just notifying the player that he changed the rims successfuly
} else {
SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have the premissions to use that cmd."); // This message is a part of the Admin check, if it fails it will display the message above, if not, it will display the success message.
}