29.11.2011, 18:50
(
Последний раз редактировалось ivanVU; 29.11.2011 в 19:33.
)
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.
ZCMD
SSCANF
and you have to define it at the top of your script
Код:
#include <a_samp> #include <zcmd> #include <sscanf2>
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; }
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
Код:
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
Код:
new CAR[3];
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
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; }
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."); }
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