how to detect if player if godmode enabled?
#1

Hi I have here a godmode

Код:
CMD:god(playerid, params[])
{
    if(GetPVarInt(playerid, "GodMode") == 0) 
    {
        SetPlayerHealth(playerid, INFINITY);   
        SetPVarInt(playerid, "GodMode", 1);    
    }
    else if(GetPVarInt(playerid, "GodMode") == 1) 
    {
        ResetPlayerWeaponsExcluding( playerid, 46 );
        SetPlayerHealth(playerid, 100.0);  
        SetPVarInt(playerid, "GodMode", 0);    
    }
    return 1;
}
But at the same time I also want to know if I do admin commands to a player which his god mod is enabled to Show game text for player. Like "Player is Godmode"

Here are the following admin commands to show gametextforplayer.

Код:
CMD:burn(playerid,params[])
{
	  if(pInfo[playerid][pLevel] >= 1)
      {
           new id,Float:x, Float:y, Float:z;
           if(sscanf(params, "u", id)) return SendClientMessage(playerid, yellow, "Usage: /burn <Player ID>");
           if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
           if(pInfo[playerid][pLevel] <= pInfo[id][pLevel] && playerid != id) return ShowMessage(playerid, red, 6);
           CommandToAdmins(playerid,"burn");
           format(Jstring,sizeof(Jstring),">> You have burnt %s",GetName(id));
		   SendClientMessage(playerid,red,Jstring);
		   GetPlayerPos(id, x, y, z);
		   CreateExplosion(x, y , z + 2, 1, 10);
		   return 1;
      }
      else return ShowMessage(playerid, red, 1);
}
Код:
CMD:slap(playerid,params[])
{
	  if(pInfo[playerid][pLevel] >= 1)
      {
           new id,Float:x, Float:y, Float:z, Float:Health;
           if(sscanf(params, "u", id)) return SendClientMessage(playerid, yellow, "Usage: /slap <Player ID>");
           if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
           if(pInfo[playerid][pLevel] <= pInfo[id][pLevel] && playerid != id) return ShowMessage(playerid, red, 6);
           CommandToAdmins(playerid,"slap");
           format(Jstring,sizeof(Jstring),">> You have slapped %s",GetName(id));
		   SendClientMessage(playerid,red,Jstring);
		   GetPlayerHealth(id,Health);
		   SetPlayerHealth(id,Health-15);
		   GetPlayerPos(id, x, y, z);
		   SetPlayerPos(id,x,y,z+6);
		   return 1;
      }
      else return ShowMessage(playerid, red, 1);
}
Код:
CMD:explode(playerid,params[])
{
	  if(pInfo[playerid][pLevel] >= 3)
      {
           new id,Float:x, Float:y, Float:z;
           if(pInfo[playerid][pLevel] <= pInfo[id][pLevel] && playerid != id) return ShowMessage(playerid, red, 6);
           if(sscanf(params, "u", id)) return SendClientMessage(playerid, yellow, "Usage: /explode <Player ID>");
           if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
           CommandToAdmins(playerid,"explode");
           format(Jstring,sizeof(Jstring),">> You have exploded %s",GetName(id));
		   SendClientMessage(playerid,yellow,Jstring);
		   GetPlayerPos(id, x, y, z);
		   CreateExplosion(x, y , z, 4,10.0);
		   return 1;
      }
      else return ShowMessage(playerid, red, 1);
}
EDIT: So basically if iam a admin and I do /slap to a player, there shoould be GameTextForPlayer that will appear on my screen "Player is Godmode"
Reply
#2

If you want to show only the game text:
pawn Код:
if(GetPVarInt(id, "GodMode") == 1) return GameTextForPlayer(playerid, "~g~player uses godmode", 2500, 4);
If you want to show the game text but doing the rest of the command (like exploding/slapping them too), remove the return.
Reply
#3

Is this what you want? If i try to /slap a player that has god mode enabled; I will be sent a text saying that he has god mode enabled?
pawn Код:
CMD:slap(playerid,params[])
{
  if(pInfo[playerid][pLevel] >= 1)
  {
       new id,Float:x, Float:y, Float:z, Float:Health;
       if(sscanf(params, "u", id)) return SendClientMessage(playerid, yellow, "Usage: /slap <Player ID>");
       if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
       if(pInfo[playerid][pLevel] <= pInfo[id][pLevel] && playerid != id) return ShowMessage(playerid, red, 6);
       if(GetPVarInt(id,"GodMode") == 1) return GameTextForPlayer(playerid,"Player has Godmode enabled!",3000);
       CommandToAdmins(playerid,"slap");
       format(Jstring,sizeof(Jstring),">> You have slapped %s",GetName(id));
       SendClientMessage(playerid,red,Jstring);
       GetPlayerHealth(id,Health);
       SetPlayerHealth(id,Health-15);
       GetPlayerPos(id, x, y, z);
       SetPlayerPos(id,x,y,z+6);
       return 1;
  }
  else return ShowMessage(playerid, red, 1);
}
Reply
#4

pawn Код:
CMD:checkgod(playerid,params[])
{
      if(pInfo[playerid][pLevel] >= 1)
      {
        new id,Float:x, Float:y, Float:z;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, yellow, "Usage: /checkgod <Player ID>");
        if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(pInfo[playerid][pLevel] <= pInfo[id][pLevel] && playerid != id) return ShowMessage(playerid, red, 6);
        if(GetPVarInt(id, "GodMode") == 0)
        {
            SendClientMessage(playerid, WHITE, "Given ID is not on godmode mode.");
        }
        else
        {
            SendClientMessage(playerid, WHITE, "Given ID is on godmode mode.");
        }
        return 1;
    }
}
Reply
#5

Thanks for the help. Both works really nice.+rep to you three . But I wonder why when I do /slap or /explode someone who is GodMode Enabled. Why is he still getting damaged or his health looses? His health should still remain the same because his on Godmode.
Reply
#6

Actually if you use an infinite float for godmode, then the explosions will do nothing. The command /slap sets the health something that changes the health; however, I'm not sure what amount GetPlayerHealth would give (if you use infinite float).
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Actually if you use an infinite float for godmode, then the explosions will do nothing. The command /slap sets the health something that changes the health; however, I'm not sure what amount GetPlayerHealth would give (if you use infinite float).
Off subject: Man after I tried to add "if(GetPVarInt(id,"GodMode") == 1) return GameTextForPlayer(playerid,"Player is on God Mode",3000, 3);"

Then I tried to do /explode to someone who is on God Mode. There was no explosion? It just say Player is on God Mode... There should be an Explosion at the same time a text that will show that his on God Mode.
Reply
#8

I told you 2 ways.

The first one was if you wanted to send the game text (ONLY) and nothing else (by using return).

The second was if you wanted to send the game text and then the rest of the code in the command being executed. (Without using return).

I just didn't know which one you wanted, so I said both.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I told you 2 ways.

The first one was if you wanted to send the game text (ONLY) and nothing else (by using return).

The second was if you wanted to send the game text and then the rest of the code in the command being executed. (Without using return).

I just didn't know which one you wanted, so I said both.
Oops I didn't notice that. And Yes I removed the return and it all works like a charm. Thanks again for helping me.

Anyway I also noticed when player is GodMode enabled and I /slap him he suddenly died/killed, The Slap only took -15 of players health.
Reply
#10

It's due to the infinite float. Just ignore the health part because he's supposed to use godmode (so reducing their health is pointless).

pawn Код:
if(GetPVarInt(id, "GodMode") != 1)
{
    GetPlayerHealth(id,Health);
    SetPlayerHealth(id,Health-15);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)