[Tutorial] How to make a /goldrims [carid]
#1

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:
pawn Код:
#include <zcmd> and #include <sscanf2>
You have to place the code above, just below the "#include <a_samp>" like that:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
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.
pawn Код:
#define COLOR_LIGHTRED 0xFF99AADD
You have to place the code above, just below the "#includes" like that:
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
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:
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.
}
Reply
#2

This is really simple, even new scripters can do this, imo. Maybe you could add more commands and explain them, this then could be a worthy tutorial!
Reply
#3

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
This is really simple, even new scripters can do this, imo. Maybe you could add more commands and explain them, this then could be a worthy tutorial!
I doubt i new scripter can do this yes, they may be able to do commands in strcmp but not with sscanf and zcmd. Also why are you looking at this since you know how to do it ?
Reply
#4

Yey, another script that wasn't tested!

Quote:
Originally Posted by ZackBoolaro
Посмотреть сообщение
pawn Код:
if(IsPlayerAdmin){
Kidding me? Also you don't even check if the vehicle the mod is to be applied to exists, or if it is a valid mod for that vehicle. Applying mods to vehicles that don't support them is a very good way to crash players.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Yey, another script that wasn't tested!



Kidding me? Also you don't even check if the vehicle the mod is to be applied to exists, or if it is a valid mod for that vehicle. Applying mods to vehicles that don't support them is a very good way to crash players.
haha..it would only give errors..new scripters won't be helped by this, but they might get confused.
Reply
#6

I messed up the IsPlayerAdmin.. it happens to me all the time when i write my own scripts..
Edit: Fixed.
Reply
#7

The command is really good, since not every scripter knows how to add this, plus it works fine for me, even when I've got tons of vehicle mods.
Reply
#8

simple but good..
Reply
#9

Why am I looking at this if I know this? Err...for the same reason people above provided their opinions and pointed out mistakes. I said it's my opinion, try not to take it otherwise. End of spam
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)