12.08.2013, 17:33
(
Last edited by Heisenbergx2; 16/08/2013 at 03:27 PM.
)
Simple Car Repair Shop Tutorial
Hello everyone! I started scripting yesterday and (even though it's a pretty simple) I was surprised that I was able to create this script on my own, so I wanted to share it with you!
It's a basic script that allows you to repair you vehicle using a command in a certain place.
First Step (1st.)
The easiest way is just to open a new file in pawno with all the callbacks there.
Well anyways.. You need only this one included. Place it in the very top of the script (if you didn't open a new file).
Second Step (2st.)
We will create a pickup icon so we can see where our repairing shop is, so go to public OnGameModeInit:
Now you have created a pickup icon.
Third Step (3st.)
Allright the last thing we want to do is write the command and it's done! Go to public OnPlayerCommandText
That's about it! You can create a map icon marker for it also and add some more messages and stuff to it, but this would be the basic structure. If you spot any mistakes in it, feel free to correct me.
Hello everyone! I started scripting yesterday and (even though it's a pretty simple) I was surprised that I was able to create this script on my own, so I wanted to share it with you!
It's a basic script that allows you to repair you vehicle using a command in a certain place.
First Step (1st.)
The easiest way is just to open a new file in pawno with all the callbacks there.
Well anyways.. You need only this one included. Place it in the very top of the script (if you didn't open a new file).
pawn Code:
#include <a_samp>
We will create a pickup icon so we can see where our repairing shop is, so go to public OnGameModeInit:
pawn Code:
public OnGameModeInit()
{
CreatePickup(1239, 1 , X , Y , Z , -1);
return 1;
}
Third Step (3st.)
Allright the last thing we want to do is write the command and it's done! Go to public OnPlayerCommandText
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext , "/vrepair" , true))// The command itself. You can replace it with whatever command you like.
{
if(IsPlayerInAnyVehicle(playerid))// Check if the player is inside a vehicle.
{
if(IsPlayerInRangeOfPoint(playerid, 2.0 , X, -Y, Z))//Check if the player is on the area where the command can be executed.
{
if(GetPlayerMoney(playerid) < 750) return SendClientMessage(playerid , 0xFFFFFFFF, "You don't have enough money");
{
new vehicleid = GetPlayerVehicleID(playerid);// Gets the player's vehicle id.
SetVehicleHealth(vehicleid , 1000.0);//Sets the player's vehicle's health to full.
GivePlayerMoney(playerid , -750);//Takes an amount of money(in this case 750)from the player.
SendClientMessage(playerid , 0xFFFFFFFF , "You have repaired your vehicle for $750");//Simple message for the player.
return 1;
}
}
}
return 0;
}