[Tutorial] Fix Vehicle (ZCMD) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Fix Vehicle (ZCMD) (
/showthread.php?tid=356460)
Fix Vehicle (ZCMD) -
JustinAn - 03.07.2012
Fix Vehicle
Credits:
Zeex -
ZCMD creator.
Hello guys, today I will be showing you how to make a /repair command to fix your vehicle.
First, your going to want to define the include 'ZCMD', a fast command processor and 'a_samp' include, which gets to access functions like SendClientMessage, SendClientMessageToAll, SetWeather, SetWorldTime, SetTimer, SetTimerEx, all those functions that are in 'a_samp' include.
pawn Код:
#include <a_samp>
#include <zcmd>
Okay, now let's start with the commands.
I will put the code here, then I will explain after the code.
pawn Код:
CMD:repair(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, -1, "Your vehicle has been sucessfully repaired!");
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
return 1;
}
Now, you will see this code, this code starts off the command, like the name of the command.
pawn Код:
CMD:repair(playerid, params[])
After that, which is inside the code.
pawn Код:
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, -1, "Your vehicle has been sucessfully repaired!");
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
return 1;
Basically, this code means that if the player isn't in a vehicle, it will send a message to the player saying that they are not in a vehicle.
Also, the '!' behind the function, 'IsPlayerInAnyVehicle(playerid)), stands for if the player isn't in a vehicle, if you don't put a '!' it will stand for if the player is in a vehicle, and then you just type in the functions, repair the vehicle, send a message they repaired it.
The -1 is a color, -1 is white. You can change it to another color that you like.
pawn Код:
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
This code here basically means that if the player is in the passenger seat or any other seat other than the driver seat, it will send them a message saying that they are not in the driver seat and it won't repair the vehicle.
The -1 is a color, -1 is white. You can change it to another color that you like.
pawn Код:
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
Now, this code basically means that it will repair the player's vehicle that the player is in, and it won't repair any other vehicles that they aren't in.
pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
This code means that it will send the player a message saying that their vehicle has been sucessfully repaired.
The -1 is a color, -1 is white. You can change it to another color that you like.
pawn Код:
SendClientMessage(playerid, -1, "Your vehicle has been sucessfully repaired!");
This code, plays a sound.
The number '1133' is the sound id.
You can find other sounds at this link, and change it to a different sound you like.
The current sound I have is a SOUND_BUY_CAR_MOD.
After you will see, '0.0, 0.0, 0.0' that is the coordinates where it will play the sound, if you set all the coordinates all to 0, it will just play the sound.
pawn Код:
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
And that's it guys, my simple /repair your vehicle tutorial.
Downloads and pastebin:
Solidfiles .pwn
Solidfiles .amx
Pastebin
Re: Fix Vehicle (ZCMD) - Glint - 03.07.2012
https://sampforum.blast.hk/showthread.php?tid=356382
Please don't post the same tutorials again and again.
Re: Fix Vehicle (ZCMD) -
JustinAn - 03.07.2012
Quote:
Originally Posted by Lexi'
|
Sorry, but I didn't meant to. I wanted to make a fixing vehicle tutorial, which was I thinking of.
Re: Fix Vehicle (ZCMD) - Glint - 03.07.2012
Quote:
Originally Posted by JustinAn
Sorry, but I didn't meant to. I wanted to make a fixing vehicle tutorial, which was I thinking of.
|
However good tutorial you explained good, but please next time think of something unique.
Re: Fix Vehicle (ZCMD) -
JustinAn - 03.07.2012
Quote:
Originally Posted by Lexi'
However good tutorial you explained good, but please next time think of something unique.
|
Thanks for the compliment, also I will try to think of something unique next time.
Thanks for the tip.
Re: Fix Vehicle (ZCMD) -
LukeStephens - 04.07.2012
Umg u nooooob u stolez mah dangd tut umg umg umg.
Joke.. Unique-ness is the key my friend.
Anyway nice tutorial for someone who wasn't wanting to add stocks (Idk why).
Respuesta: Fix Vehicle (ZCMD) -
Tyrexo - 03.05.2013
This can be a command only for admin?
Re: Respuesta: Fix Vehicle (ZCMD) -
Areax - 03.05.2013
Quote:
Originally Posted by Tyrexo
This can be a command only for admin?
|
No, this command is for all players. You can add
PHP код:
if(!IsPlayerAdmin(playerid) return SendClientMessage(playerid, -1, "You are not an Rcon Admin!"))
and now is only for Rcon Admins.
Re: Fix Vehicle (ZCMD) -
qazwsx - 24.07.2013
Nice tutorial
Re: Fix Vehicle (ZCMD) -
qazwsx - 24.07.2013
Very nice tutorial..