ive added 2 team cars and when soeone from the other team tries to enter it it sais that you don't have a key.! That worked really well.Then i added another team with their cars. And it doesent work when i enter the last team (Yakuza) you can enter that car as another team without a problem I guess the problem lies here.
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#if defined FILTERSCRIPT
#define COLOR_RED 0xFF0000AA
#define SOA 1
#define LSPD 2
#define YAKUZA 3
#define SOA_COLOUR 0x00820FAA
#define LSPD_COLOUR 0x003DF5AA
#define YAKUZA_COLOUR 0x00820FAA
//kod som gцr sе att bara polis kan gе in i polisbil o soa bara kan gе i soa bike.
enum TeamCars
{
Soa,
Lspd,
Yakuza,
};
new Cars[TeamCars];
new gTeam[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Jimmy Karlsson");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" JimmysDeathmatch");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
//Hдr lдgger man till nya skins.
// Don't use these lines if it's a filterscript
//SOA BIKES
Cars[Soa] = CreateVehicle(463,694.8014,-474.0371,15.8537,90.5883,25,1,120); //Bikes
Cars[Soa] = CreateVehicle(463,694.6365,-472.5578,15.8562,91.6353,32,1,120); //Bikes
Cars[Soa] = CreateVehicle(463,694.5961,-470.9783,15.8557,88.3544,122,1,120); //Bikes
Cars[Soa] = CreateVehicle(586,694.7456,-469.3488,15.8561,90.8062,10,1,120); //Bikes
Cars[Soa] = CreateVehicle(586,694.7992,-467.5677,15.8553,87.6643,25,1,120); //Bikes
//LSPD CAR
Cars[Lspd] = CreateVehicle(597,1563.0271,-1607.2896,13.1532,356.5738,1,103,120); // p
Cars[Lspd] = CreateVehicle(597,1566.3051,-1607.6438,13.1533,356.4574,1,103,120); // //VIKTIGT dem 3 sista дr color1 color2 respawntime missa inte annars funakre ej med CreateVehicle..
Cars[Lspd] = CreateVehicle(597,1569.3734,-1607.8632,13.1551,355.5660,1,103,120); //
Cars[Lspd] = CreateVehicle(597,1572.3883,-1608.1914,13.1533,354.9926,1,103,120); // p
Cars[Lspd] = CreateVehicle(597,1559.9863,-1607.1262,13.1549,358.8587,1,103,120); // p1
//YAKUZA CARS
Cars[Yakuza] = CreateVehicle(507,1424.3392,-1844.5082,13.3193,182.0784,0,0,120); // y
Cars[Yakuza] = CreateVehicle(507,1427.0607,-1844.3518,13.3191,181.2874,0,0,120); // y1
Cars[Yakuza] = CreateVehicle(507,1430.2900,-1844.1287,13.3176,182.3882,0,0,120); // y2
Cars[Yakuza] = CreateVehicle(507,1433.7784,-1844.2616,13.3184,181.8427,0,0,120); //
Cars[Yakuza] = CreateVehicle(507,1437.0242,-1843.9945,13.3189,181.0168,0,0,120); // y5
SetGameModeText("JimmysDeathmatch");
//SOA
AddPlayerClass(247, 1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
AddPlayerClass(248,1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
//LSPD
AddPlayerClass(280, 1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
AddPlayerClass(281,1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
//YAKUZA
AddPlayerClass(117,1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
AddPlayerClass(118,1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
AddPlayerClass(120,1545.7916,-1675.6432,13.5611,92.1874,0,0,0,0,0,0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
//Hдr har jag gjt sе att positionen дr vid polisstation
//Camerapositionen tittar pе skinnens
//Cameralookat tittar pе skinnens
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerTeamFromClass(playerid, classid); //gцr sе classen дndras till ett team!
GivePlayerMoney(playerid, 15000); //han fеr 15000kr nдr han spawnar
SetPlayerPos(playerid, 1483.5361,-1713.5564,14.0469);
SetPlayerFacingAngle(playerid, 181.8816);
SetPlayerCameraPos(playerid, 1483.4851,-1704.9474,14.0469);
SetPlayerCameraLookAt(playerid, 1483.5361,-1713.5564,14.0469);
return 1;
}
//Allt detta sker nдr nеgon connectar
public OnPlayerConnect(playerid)
{
new string[256];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));//denna koden sдger till scriptet att ta personen som connectars player name =)
format(string, sizeof(string), "Welcome to the server %s fore tutorials and stuff visit http://random.com",playername);
SendClientMessage(playerid,0xAA3333AA,string); //Stringen gцr sе det i stringen цver
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid); //Nдr dom vдljer skin sе ska rдtt nametag o color vдljas det lцser den hдr.
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendClientMessage(killerid,0xAA3333AA,"You murdered a man, and also stole his wallet with 500$ in it, hope no one saw you!");//Om du mцrdar nеgon fеr du detta meddelandet
GivePlayerMoney(killerid, 500); //om man mцrdar nеgon fеr man 500$ (du rеnar han RP int ekommit sе lеngt дn ;) )
SendClientMessage(playerid,0xAA3333AA,"You were murdered and robbed for 500$, watch out next time!"); //om du blir mцrdad fеr du detta meddelandet
GivePlayerMoney(playerid, -500);//om man dцr fцrlorar man 600
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
//Hдr gцr jag kommands man kan anvдnda i spelet
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
if (strcmp("/buymp5", cmdtext, true, 10) == 0)
{
GivePlayerWeapon(playerid, 29,200);
GivePlayerMoney(playerid, -15000); //om du skriver /buymp5 sе "kцper" du en mp5 med 200 skott fцr 15000
return 1;
}
if (strcmp("/teleportspawn", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 1545.3984,-1675.6747,13.5603); //X, Y, Z
return 1;
}
if (strcmp("/helpme", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,0xAA3333AA,"For all the commands/jobs/location etc go to http://random.com");
return 1;
}
if (strcmp("/teleport1", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 2442.7378,-1279.5771,24.0000); //X, Y, Z
return 1;
}
//denna koden under gцr sе att jag kan spawna en bil, lite mera kompliserat
if(strcmp("/admincar", cmdtext, true, 5) == 0){
new Float:x, Float:y, Float:z, Float:az;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, az);
CreateVehicle(429, x+5, y+5, z, az, -1, -1, 180);
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == Cars[Soa] )
{
if(gTeam[playerid] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
if(CarCheck == Cars[Lspd] )
{
if(gTeam[playerid] != 2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
if(CarCheck == Cars[Yakuza] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
return 1;
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = SOA;
}
if(classid == 1)
{
gTeam[playerid] = LSPD;
}
if(classid == 2)
{
gTeam[playerid] = YAKUZA;
}
}
SetPlayerToTeamColor(playerid)
{
if(gTeam[playerid] == SOA)
{
SetPlayerColor(playerid,SOA_COLOUR); //Green
}
if(gTeam[playerid] == LSPD)
{
SetPlayerColor(playerid,LSPD_COLOUR); // Blue
}
if(gTeam[playerid] == YAKUZA)
{
SetPlayerColor(playerid,YAKUZA_COLOUR); // Blue
}
}