Problem with team's car
#1

Hello! I have a problem with team's car. It works just for one car, not for all of them.
My commands are a little bit strange. For example, Grove:
if(strcmp(cmd, "/joingrove", true) == 0) {
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerPos(playerid, 2499.0161,-1683.6827,13.3933);
SendClientMessage(playerid, COLOR_GREEN, "You are now in GROVE.");
SetPlayerSkin(playerid,106);
SetPlayerColor(playerid,COLOR_GREEN);
GivePlayerWeapon(playerid,1,1);
GivePlayerWeapon(playerid,4,1);
GivePlayerWeapon(playerid,18,10);
GivePlayerWeapon(playerid,24,350);
GivePlayerWeapon(playerid,29,1000);
GivePlayerWeapon(playerid,47,1);


gTeam[playerid] = team_grove;
// now you can easily know if he is in grove or not
return 1;
Reply
#2

I don't understand what you are getting at? Do you want to restrict the usage of cars to certain teams and so on?

If so use this https://sampwiki.blast.hk/wiki/SetPlayerTeam and create arrays for each team's vehicles. Then you can use the OnPlayerEnterVehicle and use it to verify whether that vehicle is part of the xvehiclearray and whether that player is part of the team.
Reply
#3

Me i know you most follow this : (sorry for my bad english)

1- you have 2 teams and you have 8 cars 4 for team 1 & 4 for team 2
add this Line
Quote:

enum TeamCars{team1,team2} // you can add , other team //

team1 team2 are already defined in define teams



2-and add the two line belew
Quote:

new team1[50]; // 50 the number max of veh //
new team2[50];



3- Adding Cars : this is simple example

team 1

Quote:

team1[0] = AddStaticVehicle(519,1806.1066,-2406.8108,14.4731,220.1901,1,1);
team1[1] = AddStaticVehicle(519,1851.0873,-2397.0818,14.4738,221.0776,1,1);
team1[2] = AddStaticVehicle(519,1881.2903,-2364.6726,14.4760,231.6925,1,1);
team1[3] = AddStaticVehicle(593,1990.4940,-2400.4700,14.0069,126.8314,58,;]

team 2

Quote:

team2[0] = AddStaticVehicle(519,1806.1066,-2406.8108,14.4731,220.1901,1,1);
team2[1] = AddStaticVehicle(519,1851.0873,-2397.0818,14.4738,221.0776,1,1);
team2[2] = AddStaticVehicle(519,1881.2903,-2364.6726,14.4760,231.6925,1,1);
team2[3] = AddStaticVehicle(593,1990.4940,-2400.4700,14.0069,126.8314,58,;

4- Now we configure the output of cars


PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == 2)
    {
       new 
CarCheck GetPlayerVehicleID(playerid);
       if(
CarCheck == team1[0] || CarCheck == team1[1] || CarCheck == team1[2] || CarCheck == team1[3] )
       {
          if(
gTeam[playerid] != team1)
          {
              
RemovePlayerFromVehicle(playerid);
              
SendClientMessage(playerid0xFFFF00AA"TEAM 1 Alert You dont have the Key ");
              return 
1;
          }
       }
       if(
CarCheck == team2[0] || CarCheck == team2[1] || CarCheck == team2[2] || CarCheck == team2[3] )
       {
          if(
gTeam[playerid] != team2)
          {
             
RemovePlayerFromVehicle(playerid);
             
SendClientMessage(playerid0xFFFF00AA"TEAM 2 Alert You dont have the Key ");
             return 
1;
          }
        }
        return 
1;
    }
    return 
1;

Reply
#4

I solved it. Thanks to both of you! Rep+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)