GetPlayerTeam [Help]
#1

Firstly I'll explain my problem, I have Hunter Helicopters on my server and I don't want other team players to use them. So far I also have a lock for Score. As it will detect the player's score and only if their score is more than 2000, the "Army" team player is allowed to use the vehicle, but if that individual team player's score is less than 2k, then they are not allowed to enter. What I would want to implement here is, I want the player to have more than 2k score but also at the same time, must* be in the Team of Army. My team "Army" ID is 9

Here is the code I have at the moment under OnPlayerEnterVehicle

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 425)
    {
        if(GetPlayerScore(playerid) < 2000)
        {
            SetVehicleParamsForPlayer(vehicleid, playerid, false, true);
	    SendClientMessage(playerid, 0xFF0000FF, "You must be in team army and must have the score 2000 to drive a Hunter!");
        }
    }
Can anyone provide me the code to do so? +REP. Also can someone show me a simple command using the GetPlayerTeam?
Reply
#2

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 425)
    {
        if(GetPlayerScore(playerid) < 2000 && GetPlayerTeam(playerid) != 9)
        {
        	SetVehicleParamsForPlayer(vehicleid, playerid, false, true);
            SendClientMessage(playerid, 0xFF0000FF, "You must be in team army and must have the score 2000 to drive a Hunter!");
		}
    }
    return 1;
}
A simple command:

Код:
new team_names[][] =
{
"Team0 name",
"Team1 name",
"Team2 name",
"Team3 name"//and so on
};

CMD:myteam(playerid,params[])
{
	new team = GetPlayerTeam(playerid);//store the player's team
	new str[32];
	format(str,32,"Your team is: %s",team_names[team]);
	SendClientMessage(playerid,0,str);
	return 1;
}
Reply
#3

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(
GetVehicleModel(vehicleid) == 425)
    {
        if(
GetPlayerTeam(playerid) != && GetPlayerScore(playerid) < 2000)
        {
            new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxy, (0.5));
            
SendClientMessage(playerid0xFF0000FF"You must be in team army and must have the score 2000 to drive a Hunter!");
        }
    } 
Reply
#4

Paulice, your changing the player's position? Also thanks to both of ya'll but I need a simple command, using strcmp and maybe something with the use of functions such as GetPlayerTeam instead of defining them in the beginning cause I already have with the ID's, so please try to give me a simple command, by checking the Team ID and sending the message, else send a client message, your not in that team.... Thank you.
Reply
#5

You aren't unlocking the vehicle anywhere, setting the player's position a tad above will prevent them from entering.

GetPlayerTeam returns the ID set with SetPlayerTeam (if you've used it before on a player).
Reply
#6

Use ClearAnimations() to stop them from entering. Should be more effective then setting their position and simpler.
Reply
#7

Okay, that's a pretty simple command:

Код:
	if (strcmp("/army", cmdtext, true, 10) == 0)
	{
		if(GetPlayerTeam(playerid) == 9)//If his team equals 9 (Army)
		{
			SendClientMessage(playerid,0,"You are in the army");
		}else{ // else (His team NOT equals 9
			SendClientMessage(playerid,0,"You are NOT in the army!");
		}
		return 1;
	}
Reply
#8

Hey guys, my own code I provided works and doesn't allow a player with more than 2000 inside the Hunter but now with another check such as the Team check, its totally bonkers now. I tried with Different Team, with more than 2000 score, I entered the Hunter....., I after that tried as the same team, low score and I even Entered. You guys should try it yourself. Something wrong here.....

EDIT: Sorry I mean less than 2000 score. Not MORE
Reply
#9

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 425)
    {
        if(GetPlayerTeam(playerid) == 9)
        {
            if(GetPlayerScore(playerid)  < 2000)
			{
            	ClearAnimations(playerid);
            	SendClientMessage(playerid, 0xFF0000FF, "You must have the atleast 2000 score to drive a Hunter!");
            }
        }else{
            ClearAnimations(playerid);
           	SendClientMessage(playerid, 0xFF0000FF, "You must be in team army and must have the score 2000 to drive a Hunter!");
		}
    }
	return 1;
}
Reply
#10

Rolux, I played as a different team with a different ID and I still managed to enter the Hunter, even when my score was less than 2000 then I changed as Army with the ID 9, this time it stopped me because my score was less then I changed my score to 2000 and then I could enter. So some small problem is here.... any idea?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)