GodMode on/off
#1

good morning everbody^^,
i need a little code to turn GodMode on or off for only the player.

The command should be the same to turn on or off.

There is my GodMode:
pawn Код:
public GodMode(playerid)
{
for (new i = 0; i < MAX_VEHICLES; i++)
{
    for (new id = 0; id < MAX_PLAYERS; id++)
    {
        if(GetPlayerHealth(id) <= 99) {
        SetPlayerArmour(id, 100);
        SetPlayerHealth(id, 100);
}
            RepairVehicle(i);
        }
    }
}
return 1;
}
Reply
#2

Lol, why public?You should make a command
pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
SetPlayerHealth(playerid,10000000000000000);
SetPlayerArmour(playerid,1000000000000);
SendClientMessage(playerid,green,"GodMode ON!");
} else {
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SendClientMessage(playerid,red,"GodMode OFF!");
return 1;
}
Should work
Reply
#3

Quote:
Originally Posted by ikarus
Lol, why public?You should make a command
pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
SetPlayerHealth(playerid,10000000000000000);
SetPlayerArmour(playerid,1000000000000);
SendClientMessage(playerid,green,"GodMode ON!");
} else {
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SendClientMessage(playerid,red,"GodMode OFF!");
return 1;
}
Should work
Lol that would either set his health low or kill him,

SetPlayerHealth(playerid, 100000);

Is correct
Reply
#4

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by ikarus
Lol, why public?You should make a command
pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
SetPlayerHealth(playerid,10000000000000000);
SetPlayerArmour(playerid,1000000000000);
SendClientMessage(playerid,green,"GodMode ON!");
} else {
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SendClientMessage(playerid,red,"GodMode OFF!");
return 1;
}
Should work
Lol that would either set his health low or kill him,

SetPlayerHealth(playerid, 100000);

Is correct
I dont think so.
Reply
#5

i thought to much Health will kill the person :S
Reply
#6

Make a timer that might work 2, if it activates fast enough.. But that might cause lag :b
Reply
#7

I need it so:

When a player open a Dialog, where he can click on GodMode.
That the GodMode will start, when he hasnt GodMode on.

But when GodeMode is on, turn it off.

And when the Player die, the GodMode should be turned on/off too.
Reply
#8

A timer doesn't cause lag If It just sets a players health.
Since you forwarded the "public", It can be used as a timer.

pawn Код:
new God[MAX_PLAYERS]; // At the top of your script

if(strcmp(cmdtext,"/god",true)==0)
{
if(God[playerid]==1){
God[playerid]==0;
SendClientMessage(playerid, COLOR_WHITE, "GodMode has been inactivated");
}else{
God[playerid]==1;
SendClientMessage(playerid,COLOR_WHITE, "GodMode has been activated");
}
return 1;
}


// I also made an edit for this to work;

public GodMode(playerid)
{
for (new i = 0; i < MAX_VEHICLES; i++)
{
for (new id = 0; id < MAX_PLAYERS; id++)
{
    if(God[id]==1) {
    SetPlayerArmour(id, 100);
    SetPlayerHealth(id, 100);
}
       RepairVehicle(i);
    }
  }
}
return 1;
}

// Also put;

God[playerid]==0;

//Under OnPlayerDeath & OnPlayerDisconnect, and OnPlayerConnect.
You might have to fix some small errors, I'm tired and I'm at school, so I gotta go.
Reply
#9

Quote:
Originally Posted by _soad_
I need it so:

When a player open a Dialog, where he can click on GodMode.
That the GodMode will start, when he hasnt GodMode on.

But when GodeMode is on, turn it off.

And when the Player die, the GodMode should be turned on/off too.
Lol, if he has GodMode he can't die whatever here's the code:
pawn Код:
#define Dialog_God 1 // put this where are the other #defines
pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
ShowPlayerDialog(playerid,Dialog_God,0,"GodMode","On","Off");
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==Dialog_God)
{
if(response)
{
SetPlayerHealth(playerid,10000000);
SetPlayerArmour(playerid,100000);
}
else
{
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
}
}
return 1;
}
Reply
#10

Quote:
Originally Posted by ikarus
Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by ikarus
Lol, why public?You should make a command
pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
SetPlayerHealth(playerid,10000000000000000);
SetPlayerArmour(playerid,1000000000000);
SendClientMessage(playerid,green,"GodMode ON!");
} else {
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SendClientMessage(playerid,red,"GodMode OFF!");
return 1;
}
Should work
Lol that would either set his health low or kill him,

SetPlayerHealth(playerid, 100000);

Is correct
I dont think so.
Why dont you try it ingame..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)