public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } return 1; }
public OnPlayerUpdate(playerid) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } return 1; }
if (strcmp("/godmode", cmdtext, true, 10) == 0) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: Use /godmode [on/off]."); return 1; } if (strcmp("/godmode on", cmdtext, true, 11) == 0) { if (Administrator[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); GodMode[playerid] = 1; SendClientMessage(playerid, COLOR_GREEN, "Godmode enabled, use /godmode off to disable it."); } else { SendClientMessage(playerid, 0xFF0000AA, "You need to be an administrator to enable Godmode!"); } return 1; } if (strcmp("/godmode off", cmdtext, true, 12) == 0) { if (Administrator[playerid] == 1) { SetPlayerHealth(playerid, 100); GodMode[playerid] = 0; SendClientMessage(playerid, COLOR_GREEN, "Godmode disabled, use /godmode on to enable it."); } return 1; }
Hey everyone,
I've currently got a godmode command which makes the player not die when falling or being shot, but it doesn't work when the player crashes his airplane, or if he stays inside a car that is exploding. I'm currently both using OnPlayerTakeDamage AND OnPlayerUpdate to check if the player is getting damaged. Код HTML:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } return 1; } Код HTML:
public OnPlayerUpdate(playerid) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } return 1; } Код HTML:
if (strcmp("/godmode", cmdtext, true, 10) == 0) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: Use /godmode [on/off]."); return 1; } if (strcmp("/godmode on", cmdtext, true, 11) == 0) { if (Administrator[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); GodMode[playerid] = 1; SendClientMessage(playerid, COLOR_GREEN, "Godmode enabled, use /godmode off to disable it."); } else { SendClientMessage(playerid, 0xFF0000AA, "You need to be an administrator to enable Godmode!"); } return 1; } if (strcmp("/godmode off", cmdtext, true, 12) == 0) { if (Administrator[playerid] == 1) { SetPlayerHealth(playerid, 100); GodMode[playerid] = 0; SendClientMessage(playerid, COLOR_GREEN, "Godmode disabled, use /godmode on to enable it."); } return 1; } |
public OnPlayerDeath(playerid, killerid, reason) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } else { PlayerInfo[killerid][pKills]++; PlayerInfo[playerid][pDeaths]++; } return 1; }
Tried
Код HTML:
public OnPlayerDeath(playerid, killerid, reason) { if (GodMode[playerid] == 1) { SetPlayerHealth(playerid, 0x7F800000); } else { PlayerInfo[killerid][pKills]++; PlayerInfo[playerid][pDeaths]++; } return 1; } And it's okay, thanks for trying though, haha |
For vehicles you need to make a timer healing the vehicle at least each 4-5 seconds. Or set the vehicle's health to 10000000.0 if the player gets into a vehicle.
It's not possible to prevent the player from dying if the vehicle explodes, the plane explodes isntantly when crashing. |