God Command -
Lixyde - 08.03.2018
So, as title says, i want a command for /god but not that normal which when you type
/god it makes you really god mode,
I want it when you type /god the player doesn't have access to a weapons if he tries, it doesn't give the player weapons and says that in god mode can't have weapons
and a command maybe like a: /godoff to make the god mode off and to make you use weapons again.
I know maybe its easy but im new :P
Re: God Command -
ivndosos - 08.03.2018
Use ResetPlayerWeapons, and make a check to see if a player is in god mode
"new IsPlayerGod[MAX_PLAYERS];"
Re: God Command -
RxErT - 08.03.2018
PHP код:
new GodMode[MAX_PLAYERS];
CMD:god(playerid,params[])
{
if(GodMode[playerid] == 0)
{
GodMode[playerid] = 1;
SendClientMessage(playerid, -1, "You're now on duty");
SetPlayerArmedWeapon(playerid, 0);
}
else
{
if(GodMode[playerid] == 1)
{
GodMode[playerid] = 0;
SendClientMessage(playerid,-1,"You're now off duty");
}
return 1;
}
EDIT: As an example of what invo said but without
ResetPlayerWeapons(playerid);.
Re: God Command -
Lixyde - 08.03.2018
Ok that will do it! but how to do if player gets an weapon it automatic removes the weapon.
And says that he can't have weapons if it is god mode
Sorry for my bad english
Re: God Command -
KaRToNiToS - 08.03.2018
Simple,
Check if the player is on god mode, and then reset his weapons.
Re: God Command -
Lixyde - 08.03.2018
Code for this? (Sorry, i hard understand)
Re: God Command -
KaRToNiToS - 08.03.2018
I would suggest you to learn to basics through SA-MP Wiki
https://sampwiki.blast.hk/wiki/Scripting_Basics
You will not learn anything if you get free codes, Try to script it and if you get any issues post it here and we will help you.
Re: God Command -
Lixyde - 09.03.2018
Ok i made it like this:
CMD:god(playerid, params[])
{
if(GodMode[playerid] == 0)
{
GodMode[playerid] = 1;
SendClientMessage(playerid, -1, "You're now on duty");
SetPlayerArmedWeapon(playerid, 0);
ResetPlayerWeapons(playerid);
}
else
{
if(GodMode[playerid] == 1)
{
GodMode[playerid] = 0;
SendClientMessage(playerid,-1,"You're now off duty");
}
return 1;
}
And i think that should work: I added ResetPlayerWeapons(playerid);
And this should reset weapons if he have when it launch the command.
But i have other problem, how do i make when player gets weapon it removes it again? When its god mode.
Re: God Command -
AdamsLT - 09.03.2018
To remove weapons again, you should add a check in a constantly looping second timer or OnPlayerUpdate or whatever to reset the weapons IF the player is in godmode.
To avoid using a timer (if you don't have one already), you could just null the damage sent by the player in godmode so that nobody is hurt by his weapons so that you don't even need to remove them in the first place. I believe you can do that by checking if the player has godmode activated in OnPlayerWeaponShot and returning 0.