Team Cars -
ivanVU - 29.11.2011
Team Cars/Vehicles
Introduction- In this tutorial,i will show you how to make "Team Cars", this tutorial is recomended for gamemodes from "scratch",and i use this system on my gamemode,it work's 100% if you make it good.
Includes
ZCMD
SSCANF
and you have to define it at the top of your script
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Creating Vehicles
You have to go ingame and spawn some vehicles,
List of vehicles :
https://sampwiki.blast.hk/wiki/Vehicle_Model_ID_List
Command for spawnig vehicles is :
Код:
CMD:veh(playerid, params[])
{
new vehicle,Color1,Color2,delay,Float:X,Float:Y,Float:Z,Float:angle; // defining all stufs
if(sscanf(params, "iiii", vehicle, Color1, Color2, delay)) return SendClientMessage(playerid, -1, "USE: /vehicle [car id] [color 1] [color 2] [delay]"); // sscanf that check if you write it well.
GetPlayerPos(playerid, X, Y, Z); // gets your position
CreateVehicle(vehicle, X, Y + 2, Z, angle, Color1, Color2, delay); // spawns vehicle
SendClientMessage(playerid, -1, "Spawned!"); // sending message to you
return true;
}
Enter in the car,park it wherever you want,and while you are in the vehicle, type /save Car1 , or /save whateveryouwant.
Putting vehicles into script
Go on start>search , and type in "savedpositions" (without quotes) ,
after you open savedpositions you'l get some codes,
It looks like this
Код:
AddStaticVehicle(448,2119.3611,-1776.7987,12.9909,88.5099,151,1); // Car1
AddStaticVehicle(448,2119.2058,-1771.6847,12.9933,94.7364,151,1); // Car2
AddStaticVehicle(448,2119.0703,-1765.4340,12.9952,81.5577,151,1); // Car3
Copy them and write it with array's , starting from 0 , like this :
Код:
CAR[0] = AddStaticVehicle(448,2119.3611,-1776.7987,12.9909,88.5099,151,1); // CAR1
CAR[1] = AddStaticVehicle(448,2119.2058,-1771.6847,12.9933,94.7364,151,1); // CAR2
CAR[2] = AddStaticVehicle(448,2119.0703,-1765.4340,12.9952,81.5577,151,1); // CAR3
Now go to the top of your script and define
Why [3]? - becouse you have to put one more number,so if you have 7 cars,you will put new car[7]; , becouse you started from 0
Example :
Код:
CAR[0] = AddStaticVehicle(448,2119.3611,-1776.7987,12.9909,88.5099,151,1); // Pizza2
CAR[1] = AddStaticVehicle(448,2119.2058,-1771.6847,12.9933,94.7364,151,1); // Pizza3
CAR[2] = AddStaticVehicle(448,2119.0703,-1765.4340,12.9952,81.5577,151,1); // Pizza4
CAR[3] = AddStaticVehicle(448,2119.3611,-1776.7987,12.9909,88.5099,151,1); // Pizza2
CAR[4] = AddStaticVehicle(448,2119.2058,-1771.6847,12.9933,94.7364,151,1); // Pizza3
CAR[5] = AddStaticVehicle(448,2119.0703,-1765.4340,12.9952,81.5577,151,1); // Pizza4
CAR[6] = AddStaticVehicle(448,2119.3611,-1776.7987,12.9909,88.5099,151,1); // Pizza2
+ One more to define,it mean that you have to define new car[7];
Making Callback
Now,you have to go to the end of your script and put this :
Код:
stock IsATEAMCar(carid)
{
if(carid == CAR[0] || carid == CAR[1] || carid == CAR[2]) // Check if that's that vehicles
{
return 1;
}
return 0;
}
Making Check
Go to OnPlayerEnterVehicle and put :
Код:
if(IsATEAMCar(vehicleid))
{
if(PlayerInfo[playerid][pLeader] != 1 && PlayerInfo[playerid][pMember] != 1) return SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]),SendClientMessage(playerid, -1,"You are not a part of team.");
}
if(PlayerInfo[playerid][pLeader] != 1 && PlayerInfo[playerid][pMember] != 1)
You have to put your own variables,or it won't work..
This will refuse player to get in TEAM vehicle,and send him mesage that he's not a part of team..
Credits
****** - sscanf
Zeex - ZCMD
Samp Team - a_samp
IvanVU - Creating TUTorial
Gagi - Learning me how to script
Matt - /veh command
Re: Team Cars -
sleepysnowflake - 29.11.2011
Well, good. Just that wrong forum.
http://forum.sa-mp.com/forumdisplay.php?f=17
EDIT: Y'all good now.