What's new

Solved Help creating a simple script (Give health, armour and weapon)

D

Duck

Quack Quack!
Messages
7,326
Reaction score
4,855
Hello,

I'm looking to create a simple script to give myself health, armour and a weapon (assault rifle for example)

I want to start with simple scripting so it's not going to load through a menu - it will be a standalone script. I'm looking for the above to activate by pressing "SELECT" on the Xbox 360 controller.

This is all I've got so far and I don't know what to do with it

GIVE_WEAPON_TO_CHAR(Player,WEAPON_M4,AMMO_MAX,false);
SET_CHAR_HEALTH(Player,500);
ADD_ARMOUR_TO_CHAR(Player,100);

Any help would be appreciated - thank you.
 
C

Chr0m3 x MoDz

Knowledge is power, Power is corruption
VIP
Messages
5,376
Reaction score
7,928
Hello,

I'm looking to create a simple script to give myself health, armour and a weapon (assault rifle for example)

I want to start with simple scripting so it's not going to load through a menu - it will be a standalone script. I'm looking for the above to activate by pressing "SELECT" on the Xbox 360 controller.

This is all I've got so far and I don't know what to do with it

GIVE_WEAPON_TO_CHAR(Player,WEAPON_M4,AMMO_MAX,false);
SET_CHAR_HEALTH(Player,500);
ADD_ARMOUR_TO_CHAR(Player,100);

Any help would be appreciated - thank you.

Code:
#include <natives.h>
#include <common.h>
#include <strings.h>
#include <types.h>
#include <consts.h>
 
#define BUTTON_SELECT  0xD // Button definition
 
// Base made by Chr0m3 x MoDz
 
void Print(char *string) /// Print function
{
PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", string, 5000, 1);
}
 
void function(void)
{
if (IS_BUTTON_JUST_PRESSED(0, BUTTON_SELECT)) // button press anything in { and } will happen when you press select
{
GIVE_WEAPON_TO_CHAR(GetPlayerPed(),WEAPON_M4,AMMO_MAX,false);
SET_CHAR_HEALTH(GetPlayerPed(),500); /// GetPlayerPed() is a function that gets your player its in one of the header files.
ADD_ARMOUR_TO_CHAR(GetPlayerPed(),100);
Print("Ducks Mods Activated");
}
}
 
void main(void)
{
THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
while(true)
{
function();
WAIT(0);
}
}

http://www.mediafire.com/?dzl327qgcaiciir << Compiled in a .sco for you
 
Last edited:
C

Chr0m3 x MoDz

Knowledge is power, Power is corruption
VIP
Messages
5,376
Reaction score
7,928
lol - okay, thank you.

If you could show me, that would be awesome. I want to learn simple stuff first - rather than jumping in the deep end.
Done look above.
 
B

The Exemplary

Contributor
Messages
675
Reaction score
542
lol - okay, thank you.

If you could show me, that would be awesome. I want to learn simple stuff first - rather than jumping in the deep end.
This is about as simple as it gets.
 
C

Chr0m3 x MoDz

Knowledge is power, Power is corruption
VIP
Messages
5,376
Reaction score
7,928
D Duck
Also here is something for you to think about

Code:
#include <natives.h>
#include <common.h>
#include <strings.h>
#include <types.h>
#include <consts.h>
 
#define BUTTON_SELECT  0xD // Button definition
 
int check=0; /// int definition
// Base made by Chr0m3 x MoDz
 
void Print(char *string) /// Print function
{
PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", string, 5000, 1);
}
 
void function(void)
{
if (IS_BUTTON_JUST_PRESSED(0, BUTTON_SELECT)) // button press anything in { and } will happen when you press select
{
if (check == 0)
{
GIVE_WEAPON_TO_CHAR(GetPlayerPed(),WEAPON_M4,AMMO_MAX,false);
SET_CHAR_HEALTH(GetPlayerPed(),500); /// GetPlayerPed() is a function that gets your player its in one of the header files.
ADD_ARMOUR_TO_CHAR(GetPlayerPed(),100);
Print("Ducks Mods Activated");
check=1;
}
else if (check == 1)
{
Print("You have already used this.");
check=0;
}
}
}
 
void main(void)
{
THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
while(true)
{
function();
WAIT(0);
}
}

In this example the check is like this when that number goes up the scenario changes also the else is needed or it will just constantly keep counting on and changing with 1 button press

so if you pressed select once with this will give you your weapon and armour but if you press it twice it will say you have already used it then it will reset so when you press again it will do the weapon and armour again
 
D

Duck

Quack Quack!
Messages
7,326
Reaction score
4,855
C Chr0m3 x MoDz

That's even better! I'll compile the second source. Thank you very much for that extremely quick response and help!
 
C

Chr0m3 x MoDz

Knowledge is power, Power is corruption
VIP
Messages
5,376
Reaction score
7,928
C Chr0m3 x MoDz

That's even better! I'll compile the second source. Thank you very much for that extremely quick response and help!
No problem here is some other things

Code:
#define BUTTON_SELECT  0xD
#define BUTTON_START  0xC
#define BUTTON_S  0xE
#define BUTTON_T  0xF
#define BUTTON_X  0x10
#define BUTTON_O  0x11
#define BUTTON_DPAD_UP  0x8
#define BUTTON_DPAD_DOWN  0x9
#define BUTTON_DPAD_LEFT  0xA
#define BUTTON_DPAD_RIGHT  0xB
#define BUTTON_L2  0x5
#define BUTTON_R2  0x7
#define BUTTON_L1  0x4
#define BUTTON_R1  0x6
#define BUTTON_STICK_LEFT  0x12
#define BUTTON_STICK_RIGHT  0x13

That's all your button definitions.

If you want any help add me on skype jezzerdabomb. Also if you want i could show you how to make your own simple menu (Not a big menu like everyone just a simple print menu)
 
S

SBHAX

Aye so...
Messages
2,934
Reaction score
2,137
Code:
#include <natives.h>
#include <common.h>
#include <strings.h>
#include <types.h>
#include <consts.h>
 
#define BUTTON_SELECT  0xD // Button definition
 
// Base made by Chr0m3 x MoDz
 
void Print(char *string) /// Print function
{
PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", string, 5000, 1);
}
 
void function(void)
{
if (IS_BUTTON_JUST_PRESSED(0, BUTTON_SELECT)) // button press anything in { and } will happen when you press select
{
GIVE_WEAPON_TO_CHAR(GetPlayerPed(),WEAPON_M4,AMMO_MAX,false);
SET_CHAR_HEALTH(GetPlayerPed(),500); /// GetPlayerPed() is a function that gets your player its in one of the header files.
ADD_ARMOUR_TO_CHAR(GetPlayerPed(),100);
Print("Ducks Mods Activated");
}
}
 
void main(void)
{
THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
while(true)
{
function();
WAIT(0);
}
}

http://www.mediafire.com/?dzl327qgcaiciir << Compiled in a .sco for you
I done something similar to that and I froze :frown:
 
Top Bottom