SA-MP Forums Archive
gteam help. - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: gteam help. (/showthread.php?tid=261471)



gteam help. - krisis32 - 13.06.2011

Why can BANK and POLICE team members enter AMB teams cars? AMB cars is only for AMB members.
I have ******d and tryed alot of things, but nothing works!
Here is the code:
Код:
enum TeamCars
{
Bank,
Police,
Amb
}
new Cars[TeamCars];
new gTeam[MAX_PLAYERS];
#define BANK 0
#define POLICE 1
#define AMB 2
#define BANK_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA
#define AMB_COLOUR 0x003DF5AA

public OnGameModeInit()
{
	AddPlayerClass(163,-817.0843,1514.4772,20.3744,92.4108,0,0,0,0,0,0); //Bank
	AddPlayerClass(164,-817.0843,1514.4772,20.3744,92.4108,0,0,0,0,0,0); //Bank
	AddPlayerClass(280,-1388.9767,2624.5515,55.9844,74.2934,0,0,0,0,0,0); //Police Officer
    AddPlayerClass(274,-1513.8643,2526.5891,55.7543,345.4217,0,0,0,0,0,0); //Ambulance
    AddPlayerClass(276,-1513.8643,2526.5891,55.7543,345.4217,0,0,0,0,0,0); //Ambulance
    Cars[Police] = AddStaticVehicle(497,-1406.1665,2669.4944,58.2696,92.2791,94,72); //Police Maverick
    Cars[Police] = AddStaticVehicle(597,-1400.0337,2653.1772,55.4573,90.1835,94,72); //Police
    Cars[Police] = AddStaticVehicle(597,-1400.0476,2646.9023,55.4553,88.7202,94,72); //Police
    Cars[Police] = AddStaticVehicle(597,-1399.7706,2640.5942,55.4570,89.7243,94,72); //Police
    Cars[Police] = AddStaticVehicle(599,-1400.1295,2634.4502,55.9129,90.3322,94,72); //Police Rancher
    Cars[Police] = AddStaticVehicle(599,-1400.0939,2628.7153,55.9641,89.5174,94,72); //Police Rancher
    //Ambulance //
    Cars[Amb] = AddStaticVehicle(417,-1486.5945,2504.0725,57.6180,357.3611,17,72); //ambulance helicopter
    Cars[Amb] = AddStaticVehicle(416,-1509.9624,2525.1782,55.8363,1.3122,17,72); //ambulance
    Cars[Amb] = AddStaticVehicle(416,-1503.4385,2525.1799,55.8366,0.7995,17,72); //ambulance
    Cars[Amb] = AddStaticVehicle(416,-1519.4072,2525.1855,55.8413,1.1643,17,72); //ambulance
    Cars[Amb] = AddStaticVehicle(416,-1525.9128,2525.3967,55.9056,1.0442,17,72); //ambulance
    //Securicar //
    Cars[Bank] = AddStaticVehicle(428,-820.8925,1518.1023,20.5814,180.7465,90,4); //Bank Securicar
	return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = BANK;
    }
    if(classid == 1)
    {
        gTeam[playerid] = BANK;
    }
    if(classid == 2)
    {
        gTeam[playerid] = POLICE;
    }
    if(classid == 3)
    {
        gTeam[playerid] = AMB;
    }
    if(classid == 4)
    {
        gTeam[playerid] = AMB;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == BANK)
    {
        SetPlayerColor(playerid,BANK_COLOUR); //Green
    }
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOUR); // Blue
    }
    if(gTeam[playerid] == AMB)
    {
        SetPlayerColor(playerid,AMB_COLOUR); // Blue
    }
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);

	return 1;
}

public OnPlayerSpawn(playerid)
{
  SetPlayerToTeamColour(playerid);
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
    new CarCheck = GetPlayerVehicleID(playerid);
    if(CarCheck == Cars[Bank] )
    {
    if(gTeam[playerid] != BANK)
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid, COLOR_RED, "You are not General Banks Security Men!");
    return 1;
    }
    }
    if(CarCheck == Cars[Police] )
    {
    if(gTeam[playerid] != POLICE)
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid, COLOR_RED, "You are not Police Offircer!");
    return 1;
    }
    }
    if(CarCheck == Cars[Amb] )
    {
    if(gTeam[playerid] != AMB)
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid, COLOR_RED, "You are not Doctor!");
    return 1;
    }
    }
    return 1;
    }
    return 1;
}



Re: gteam help. - L84S - 13.06.2011

Then make public here is an example:
First new ambcar [5]
else
Код:
forward IsAmb (Carid);
and then do that:
Код:
 public IsAmb (Carid)
{
for (new i = 0; i <sizeof (Ambcar) i + +)
{
if (Caridi == Amb [i]) return 1;
}
return 0;
}
Note then you have to work like this a car :
ambcar[0] = AddStaticVehicle(417,-1486.5945,2504.0725,57.6180,357.3611,17,72); //ambulance helicopter
ambcar[1] = ................................
ambcar[2] =...................................
ambcar[3] =.................................
ambcar[4] =......................................


Re: gteam help. - krisis32 - 13.06.2011

But why is it not working how i made it? BANK cars can only enter BANK members , POLICE cars can only enter POLICE members, AMB cars can enter everyone! WHY??


Re: gteam help. - krisis32 - 14.06.2011

bump