Check If Player Is Drunk By Police
#1

Is there a way that the police could check and see if the player is drunk. and get what there intoxication level is.


I have been trying to make this for weeks and i have failed. Help Please




Reply
#2

GetPlayerDrunkLevel(playerid);
Reply
#3

Yes I know that lol. I just need something to go from
Reply
#4

try making a command that uses
Quote:
Originally Posted by Anwix
GetPlayerDrunkLevel(playerid);
to determine what level of "drunken-ness" said player is at, and report it back to the user.
Reply
#5

Код:
dcmd_drunk(playerid, params[])
{
	new tmp[256], Index;
	tmp = strtok(params,Index);
	new otherid = strval(tmp);
	
	if (strlen(tmp))
	{
		if (IsPlayerConnected(otherid))
		{
		  new string[256], name[MAX_PLAYER_NAME];
		  GetPlayerName(otherid, name, MAX_PLAYER_NAME);
		  
		  switch (GetPlayerDrunkLevel(otherid))
		  {
		    case 0: { format(string, sizeof(string), "%s is sober!", name); }
		    case 2000: { format(string, sizeof(string), "%s is drunk!", name); }
		    case 5000: { format(string, sizeof(string), "%s is wasted!", name); }
		  }
			
		  SendClientMessage(playerid, YELLOW, string);
		}
		else
		{
		  SendClientMessage(playerid, WHITE, "That player is not online!");
		}
	}
	else
	{
	  SendClientMessage(playerid, WHITE, "USAGE: /drunk [playerid]");
	}
	return 1;
}
Untested.
Reply
#6

No I tried Modifying it to my script and it wouldn't work...
Reply
#7

Any More Ideas
Reply
#8

try this

pawn Код:
if(strcmp(cmd, "/getdrunklevel", true) == 0 || strcmp(cmd, "/gdl", true) == 0)
    {
      tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /gdl [playerid]");
            return 1;
        }
        giveplayerid = strval(tmp);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1)
        {
          if(IsPlayerInRangeOfPoint(playerid, 8.0, x , y, z))
            {
            if(GetPlayerDrunkLevel(giveplayerid) > 1 && GetPlayerDrunkLevel(giveplayerid) < 2999)
              {
                SendClientMessage(playerid,0xFFFFFFFF,"He is not drunk");
              }
            if(GetPlayerDrunkLevel(giveplayerid) > 3000 && GetPlayerDrunkLevel(giveplayerid) < 5000)
              {
                SendClientMessage(playerid,0xFFFFFFFF,"He is Drunk");
              }
                if(GetPlayerDrunkLevel(giveplayerid) > 3001 && GetPlayerDrunkLevel(giveplayerid) < 50000)
              {
                SendClientMessage(playerid,0xFFFFFFFF,"He is Really Drunk");
              }
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "That playerid is not close (enough) to you!");
            }
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED,"You are not a Cop");
        }
        return 1;
    }
Reply
#9

Quote:
Originally Posted by Red Hockey
Any More Ideas
Quote:
Originally Posted by Anwix
Код:
dcmd_drunk(playerid, params[])
{
	new tmp[256], Index;
	tmp = strtok(params,Index);
	new otherid = strval(tmp);
	
	if (strlen(tmp))
	{
		if (IsPlayerConnected(otherid))
		{
		  new string[256], name[MAX_PLAYER_NAME];
		  GetPlayerName(otherid, name, MAX_PLAYER_NAME);
		  
		  switch (GetPlayerDrunkLevel(otherid))
		  {
		    case 0: { format(string, sizeof(string), "%s is sober!", name); }
		    case 2000: { format(string, sizeof(string), "%s is drunk!", name); }
		    case 5000: { format(string, sizeof(string), "%s is wasted!", name); }
		  }
			
		  SendClientMessage(playerid, YELLOW, string);
		}
		else
		{
		  SendClientMessage(playerid, WHITE, "That player is not online!");
		}
	}
	else
	{
	  SendClientMessage(playerid, WHITE, "USAGE: /drunk [playerid]");
	}
	return 1;
}
Untested.
I expect this doesn't work because it is checking if the level is either 0, 2000 or 5000, when what you actually need to just check is the ranges between those values (I think). Try replacing the switch with this:

pawn Код:
GetPlayerDrunkLevel(otherid)

if(otherid < 2000) format(string, sizeof(string), "%s is sober!", name);
else if(2000 <= otherid < 5000) format(string, sizeof(string), "%s is drunk!", name);
else if(5000 <= otherid) print("3"); format(string, sizeof(string), "%s is wasted!", name);
You may want to change the value of 5000 in order to set where you want the boundary between drunk and wasted to be. Also you don't need such big string arrays.
Reply
#10

Nope Still Nothing
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)