SA-MP Forums Archive
Help for script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help for script (/showthread.php?tid=499498)



Help for script - RedbullGD - 08.03.2014

Hello everyone! hope everything's fine.
I wanted to ask how can i stop the player from buying weapons when in godmode.
my script for godmode is


Код:
#include <a_samp>
#include <zcmd>

#define red              0xFF0000AA
#define green            0x33FF33AA

new GodMode[MAX_PLAYERS];
new Float:hp[MAX_PLAYERS];
new Float:armour[MAX_PLAYERS];

CMD:godmodeon(playerid, params[])
{
    
        if(GodMode[playerid] == 0)
        {
			ResetPlayerWeapons(playerid);
            GodMode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
                        SetVehicleHealth(GetPlayerVehicleID(playerid),9999999999);
            GetPlayerHealth(playerid,hp[playerid]);
            GetPlayerArmour(playerid,armour[playerid]);
            SendClientMessage(playerid,green, "|---------------------|");
                SendClientMessage(playerid,green, "|-God-Mode-On-|");
                SendClientMessage(playerid,green, "|---------------------|");
                }
                else if(GodMode[playerid] == 1)
        {
            GivePlayerWeapon(playerid,29,150);
            GodMode[playerid] = 0;
            SetPlayerHealth(playerid,hp[playerid]);
            SetPlayerArmour(playerid,armour[playerid]);
            SetVehicleHealth(GetPlayerVehicleID(playerid),1250.0);
            SendClientMessage(playerid,red, "|---------------------|");
                SendClientMessage(playerid,red, "|-God-Mode-Off-|");
                SendClientMessage(playerid,red, "|---------------------|");
                }


        return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid,green,"This server uses scripts by Redbull[GD]");
	return 1;
}
Please help me i m new
Thanks in Advance


Re: Help for script - Matess - 08.03.2014

Reset his money? Check if he is in ammunation interior?

And this code is pointless:

SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
SetVehicleHealth(GetPlayerVehicleID(playerid),9999 999999);
GetPlayerHealth(playerid,hp[playerid]);
GetPlayerArmour(playerid,armour[playerid]);

Now in the variables (hp and armour) will be 99999


Re: Help for script - RedbullGD - 08.03.2014

bro then what script should i use to bring his money back
Please help


Re: Help for script - Matess - 08.03.2014

You can try:
new Moneys[MAX_PLAYERS]; // above armour for example

When godmode = 0
Moneys[playerid] = GetPlayerMoney(playerid);
ResetPlayerMoney(playerid);

and for backup

When godmode = 1
GivePlayerMoney(playerid,Moneys[playerid]);


Re: Help for script - tyler12 - 08.03.2014

Add something like this when the player tries to buy a weapon.

pawn Код:
if(GodMode[playerid]) return SendClientMessage(playerid,red,"ERROR: You have god mode enabled, you can't buy weapons.");



Re: Help for script - XK - 08.03.2014

if you have a command to buy weapons..
write this under it:
pawn Код:
if(GodMode[playerid])
{
       SendClientMessage(playerid, -1, "You cant buy weapons with godmode enabled.");
       return 1;
}