PDA

View Full Version : Toggle god on/off


rakshith122
26/01/2014, 10:27 AM
Well, This is my god command. Now, It turns on when I use /vgod, What I need now is, When a player types /vgod again, It should be turned off.

dcmd_vgod(playerid,params[])
{
#pragma unused params
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to go into god mode.");
return 1;
}
for(new w=0; w<13; w++)
{
GetPlayerWeaponData(playerid,w,PlayerWeapon[playerid][w],PlayerAmmo[playerid][w]);
}
SendClientMessage(playerid,COLOR_VIOLETBLUE,"You are now in god mode. You now have infinite health, armour and VIP Weapons.");
ResetPlayerWeapons(playerid);
InVIPMode[playerid] =1;

GivePlayerWeapon(playerid,24,999999);
GivePlayerWeapon(playerid,26,999999);
GivePlayerWeapon(playerid,29,999999);
GivePlayerWeapon(playerid,31,999999);
SetPlayerHealth(playerid,999999);
SetPlayerArmour(playerid,999999);
return 1;
}


Thanks in advance.

Vanter
26/01/2014, 10:32 AM
dcmd_vgod(playerid,params[])
{
#pragma unused params
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to go into god mode.");
return 1;
}
for(new w=0; w<13; w++)
{
GetPlayerWeaponData(playerid,w,PlayerWeapon[playerid][w],PlayerAmmo[playerid][w]);
}
if(InVIPMode[playerid] == 0)
{
SendClientMessage(playerid,COLOR_VIOLETBLUE,"You are now in god mode. You now have infinite health, armour and VIP Weapons.");
ResetPlayerWeapons(playerid);
InVIPMode[playerid] =1;

GivePlayerWeapon(playerid,24,999999);
GivePlayerWeapon(playerid,26,999999);
GivePlayerWeapon(playerid,29,999999);
GivePlayerWeapon(playerid,31,999999);
SetPlayerHealth(playerid,999999);
SetPlayerArmour(playerid,999999);
}
if(InVIPMode[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN,"You are no longer in God mode.");
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
InVIPMode(playerid] =0;
}
return 1;
}

rakshith122
26/01/2014, 10:40 AM
You just made some mistakes on that code, Anyways, I fixed them. Thanks.