Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

Script to select weapons using numeric keys [0-9]


Arya_Eto
 Share

Recommended Posts

Hi Friends,

 

I am writing a small script for " Selecting weapons using numeric keys [0-9]" i.e if i press numeric key ( 1 ) then player armed weapon should change to pistols (default, silenced or desert),

 

similarly if i press key ( 2 ), then player armed weapon should change to shotguns(chrome, sawn, combat) and so on for other weapon groups.

 

now i have written the script but its only working for only single keypress. that means its working only for

key ( 1 ) but not when i press other keys.

 

so i need your help to know where i am going wrong in my code.

 

 

 

below is the code [written from scratch]:

// Script to scroll through weapons using numeric keys [0-9]{$CLEO .cs}// ---------- MAIN ------------------0A95: enable_thread_saving:WS_1wait 0if and     Player.Defined($PLAYER_ACTOR)   044B:   actor $PLAYER_ACTOR on_foot   jf @WS_1     0470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 22jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2202D8:   actor $PLAYER_ACTOR current_weapon == 220470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 23jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2302D8:   actor $PLAYER_ACTOR current_weapon == 230470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 24jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2402D8:   actor $PLAYER_ACTOR current_weapon == 240470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 25jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2502D8:   actor $PLAYER_ACTOR current_weapon == 250470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 26jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2602D8:   actor $PLAYER_ACTOR current_weapon == 260470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 27jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2702D8:   actor $PLAYER_ACTOR current_weapon == 270470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 28jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2802D8:   actor $PLAYER_ACTOR current_weapon == 280470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 29jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2902D8:   actor $PLAYER_ACTOR current_weapon == 290470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 32jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3202D8:   actor $PLAYER_ACTOR current_weapon == 320470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 30jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3002D8:   actor $PLAYER_ACTOR current_weapon == 300470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 31jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3102D8:   actor $PLAYER_ACTOR current_weapon == 310470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 33jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3302D8:   actor $PLAYER_ACTOR current_weapon == 330470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed [email protected] <> 34jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3402D8:   actor $PLAYER_ACTOR current_weapon == 340470: [email protected] = actor $PLAYER_ACTOR current_weaponif Player.Wasted($PLAYER_ACTOR)jf @WS_1jump @WS_2:WS_2wait 0048F: actor $PLAYER_ACTOR remove_weaponswait 0jump @WS_10A93: end_custom_thread
Link to comment
Share on other sites

Maybe because you have it all one thread.

 

Make it:

thread 'WS':WS_1wait 0if and     Player.Defined($PLAYER_ACTOR)   044B:   actor $PLAYER_ACTOR on_foot   jf @WS_1     0470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_2if and0AB0:   key_pressed [email protected] <> 22jf @WS_301B9: set_actor $PLAYER_ACTOR armed_weapon_to 2202D8:   actor $PLAYER_ACTOR current_weapon == 220470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_3if and0AB0:   key_pressed [email protected] <> 23jf @WS_401B9: set_actor $PLAYER_ACTOR armed_weapon_to 2302D8:   actor $PLAYER_ACTOR current_weapon == 230470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_4if and0AB0:   key_pressed [email protected] <> 24jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2402D8:   actor $PLAYER_ACTOR current_weapon == 240470: [email protected] = actor $PLAYER_ACTOR current_weapon

make it so it jumps to the next thread if it's false and when it reaches the last thread it jumps to WS_1

 

 

:THREAD_01

wait 0

if

condition

jump_false @THREAD_02

 

:THREAD_02

wait 0

if

condition

jump_false @THREAD_03

 

etc....

Link to comment
Share on other sites

Rewrite in high level ;-;

 

okay buddy will do it in high level :)

 

actually i just started coding... so will take lil time to get familiar with high level coding stuff.

Link to comment
Share on other sites

Maybe because you have it all one thread.

 

Make it:

thread 'WS':WS_1wait 0if and     Player.Defined($PLAYER_ACTOR)   044B:   actor $PLAYER_ACTOR on_foot   jf @WS_1     0470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_2if and0AB0:   key_pressed 49[email protected] <> 22jf @WS_301B9: set_actor $PLAYER_ACTOR armed_weapon_to 2202D8:   actor $PLAYER_ACTOR current_weapon == 220470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_3if and0AB0:   key_pressed 49[email protected] <> 23jf @WS_401B9: set_actor $PLAYER_ACTOR armed_weapon_to 2302D8:   actor $PLAYER_ACTOR current_weapon == 230470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_4if and0AB0:   key_pressed 49[email protected] <> 24jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2402D8:   actor $PLAYER_ACTOR current_weapon == 240470: [email protected] = actor $PLAYER_ACTOR current_weapon

make it so it jumps to the next thread if it's false and when it reaches the last thread it jumps to WS_1

 

 

:THREAD_01

wait 0

if

condition

jump_false @THREAD_02

 

:THREAD_02

wait 0

if

condition

jump_false @THREAD_03

 

etc....

 

Thanks Delta :)... its working now

Link to comment
Share on other sites

Wow this code is still fairly sh*t.

Link to comment
Share on other sites

Lo tengo, se lo había dado a DC22PACK para solucionar un bug de su hud al tener 2 juagdores, ahora se lo doy



//0 - min
//46 - max
{$CLEO}
0000:
:FIRST
wait 0
if and
0256: player $PLAYER_CHAR defined
0118: not actor $PLAYER_CHAR dead
jf @FIRST
jump @ANTERIOR

:ANTERIOR
wait 0
if
00E1: player 0 pressed_key 9
jf @SIGUIENTE
046F: store_player $PLAYER_ACTOR currently_armed_weapon_to [email protected]
jump @ANTERIOR_BAK

:ANTERIOR_BAK
wait 0
if
not [email protected] == 0
jf @SET_46
000E: [email protected] -= 1
jump @ANTERIOR_SUB

:ANTERIOR_SUB
wait 0
if
0491: has_char_got_weapon $PLAYER_ACTOR weapon [email protected]
jf @ANTERIOR_BAK_POST
01B9: set_current_char_weapon $PLAYER_ACTOR to [email protected]
jump @FIRST

:SET_46
wait 0
[email protected] = 46 //procesado
jump @ANTERIOR_SUB

:ANTERIOR_BAK_POST
wait 0
000E: [email protected] -= 1
jump @ANTERIOR_SUB

:SIGUIENTE
wait 0
if
00E1: player 0 pressed_key 8
jf @ANTERIOR
046F: store_player $PLAYER_ACTOR currently_armed_weapon_to [email protected]
jump @SIGUIENTE_BAK

:SIGUIENTE_BAK
wait 0
if
not [email protected] == 46
jf @SET_0
[email protected] += 1
jump @SIGUIENTE_SUB

:SIGUIENTE_SUB
wait 0
if
0491: has_char_got_weapon $PLAYER_ACTOR weapon [email protected]
jf @SIGUIENTE_BAK_POST
01B9: set_current_char_weapon $PLAYER_ACTOR to [email protected]
jump @FIRST

:SET_0
wait 0
[email protected] = 0
jump @SIGUIENTE_SUB

:SIGUIENTE_BAK_POST
wait 0
[email protected] += 1
jump @SIGUIENTE_SUB



number Weapon Group Name ModelID Model name Icon
gift //KEY 2 (10/15)
10 11 Purple Dildo 321 #gun_dildo1
11 11 White Dildo 322 #gun_dildo2
12 11 Long White Dildo 323 #gun_vibe1
13 11 White Dildo 2 324 #gun_vibe2
14 11 Flowers 325 #flowera
15 11 Cane 326 #gun_cane
melee //KEY 1 (0/9)
0 1 Unarmed
1 1 Brass Knuckles 331 #brassknuckle
2 2 Golf Club 333 #golfclub
3 2 Night Stick 334 #nitestick
4 2 Knife 335 #knifecur
5 2 Baseball Bat 336 #bat
6 2 Shovel 337 #shovel
7 2 Pool cue 338 #poolcue
8 2 Katana 339 #katana
9 2 Chainsaw 341 #chnsaw
projectiles //KEY 3 (16/18)/G (Like GTA V)
16 9 Grenades 342 #grenade
17 9 Tear Gas 343 #teargas
18 9 Molotovs 344 #molotov
handguns //KEY 4 (22/24)
22 3 Pistol 346 #colt45
23 3 Silenced Pistol 347 #silenced
24 3 Desert Eagle 348 #desert_eagle
shotguns //KEY 5
25 4 Shotgun 349 #chromegun
26 4 Sawn Off Shotgun 350 #sawnoff
27 4 Combat Shotgun 351 #shotgspa
sub-machineguns //KEY 6
28 5 Micro Uzi (Mac 10) 352 #micro_uzi
29 5 MP5 353 #mp5lng
32 5 Tec9 372 #tec9
machineguns //KEY 7
30 6 AK47 355 #ak47
31 6 M4 356 #m4
rifles //KEY 8
33 7 Rifle 357 #c*ntgun
34 7 Sniper Rifle 358 #sniper
specials //KEY 9
35 8 RPG 359 #rocketla
36 8 Missile Launcher 360 #heatseek
37 8 Flame Thrower 361 #flame
38 8 Minigun 362 #minigun
39 9 Sachet Charges 363 #satchel
40 13 Detonator 364 #bomb
41 10 Spray Paint 365 #spraycan
42 10 Fire Extinguisher 366 #fire_ex
43 10 Camera 367 #camera
44 12 Nightvision Goggles 368 #nvgoggles
45 12 Thermal Goggles 369 #irgoggles
46 12 Parachute 371 #gun_para
Other //KEY 0
jetpack 370 #jetpack

//By Sanny Builder help

Edited by boludoz
Link to comment
Share on other sites

Weird checks, conditional commands (02D8) used as if they weren't conditional etc...

Edited by Silent
Link to comment
Share on other sites

Lol he's a beginner what do you expect?

Since you partially fixed it I'd expect you to point those out too.

Link to comment
Share on other sites

 

Hi Friends,

 

I am writing a small script for " Selecting weapons using numeric keys [0-9]" i.e if i press numeric key ( 1 ) then player armed weapon should change to pistols (default, silenced or desert),

 

similarly if i press key ( 2 ), then player armed weapon should change to shotguns(chrome, sawn, combat) and so on for other weapon groups.

 

now i have written the script but its only working for only single keypress. that means its working only for

key ( 1 ) but not when i press other keys.

 

so i need your help to know where i am going wrong in my code.

 

 

 

below is the code [written from scratch]:

// Script to scroll through weapons using numeric keys [0-9]{$CLEO .cs}// ---------- MAIN ------------------0A95: enable_thread_saving:WS_1wait 0if and     Player.Defined($PLAYER_ACTOR)   044B:   actor $PLAYER_ACTOR on_foot   jf @WS_1     0470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 49[email protected] <> 22jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2202D8:   actor $PLAYER_ACTOR current_weapon == 220470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 49[email protected] <> 23jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2302D8:   actor $PLAYER_ACTOR current_weapon == 230470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 49[email protected] <> 24jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2402D8:   actor $PLAYER_ACTOR current_weapon == 240470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 50[email protected] <> 25jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2502D8:   actor $PLAYER_ACTOR current_weapon == 250470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 50[email protected] <> 26jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2602D8:   actor $PLAYER_ACTOR current_weapon == 260470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 50[email protected] <> 27jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2702D8:   actor $PLAYER_ACTOR current_weapon == 270470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 51[email protected] <> 28jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2802D8:   actor $PLAYER_ACTOR current_weapon == 280470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 51[email protected] <> 29jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2902D8:   actor $PLAYER_ACTOR current_weapon == 290470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 51[email protected] <> 32jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3202D8:   actor $PLAYER_ACTOR current_weapon == 320470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 52[email protected] <> 30jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3002D8:   actor $PLAYER_ACTOR current_weapon == 300470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 52[email protected] <> 31jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3102D8:   actor $PLAYER_ACTOR current_weapon == 310470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 53[email protected] <> 33jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3302D8:   actor $PLAYER_ACTOR current_weapon == 330470: [email protected] = actor $PLAYER_ACTOR current_weaponif and0AB0:   key_pressed 53[email protected] <> 34jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 3402D8:   actor $PLAYER_ACTOR current_weapon == 340470: [email protected] = actor $PLAYER_ACTOR current_weaponif Player.Wasted($PLAYER_ACTOR)jf @WS_1jump @WS_2:WS_2wait 0048F: actor $PLAYER_ACTOR remove_weaponswait 0jump @WS_10A93: end_custom_thread

 

Maybe because you have it all one thread.

 

Make it:

thread 'WS':WS_1wait 0if and     Player.Defined($PLAYER_ACTOR)   044B:   actor $PLAYER_ACTOR on_foot   jf @WS_1     0470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_2if and0AB0:   key_pressed 49[email protected] <> 22jf @WS_301B9: set_actor $PLAYER_ACTOR armed_weapon_to 2202D8:   actor $PLAYER_ACTOR current_weapon == 220470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_3if and0AB0:   key_pressed 49[email protected] <> 23jf @WS_401B9: set_actor $PLAYER_ACTOR armed_weapon_to 2302D8:   actor $PLAYER_ACTOR current_weapon == 230470: [email protected] = actor $PLAYER_ACTOR current_weapon:WS_4if and0AB0:   key_pressed 49[email protected] <> 24jf @WS_101B9: set_actor $PLAYER_ACTOR armed_weapon_to 2402D8:   actor $PLAYER_ACTOR current_weapon == 240470: [email protected] = actor $PLAYER_ACTOR current_weapon

make it so it jumps to the next thread if it's false and when it reaches the last thread it jumps to WS_1

 

 

:THREAD_01

wait 0

if

condition

jump_false @THREAD_02

 

:THREAD_02

wait 0

if

condition

jump_false @THREAD_03

 

etc....

 

Thanks Delta :)... its working now

 

i do not know exactly about what in your script

it was

but

i made you the weapon selector

learn to

write scripts

also i was noob

 

 

// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagamin...opcode-database) on 14.6.2013

{$CLEO .cs}

 

//-------------MAIN---------------

0000: NOP

0000: NOP

 

 

 

Model.Load(#BRASSKNUCKLE)

Model.Load(#GOLFCLUB)

Model.Load(#NITESTICK)

Model.Load(#KNIFECUR)

Model.Load(#BAT)

Model.Load(#SHOVEL)

Model.Load(#POOLCUE)

Model.Load(#KATANA)

Model.Load(#CHNSAW)

Model.Load(#GUN_DILDO1)

Model.Load(#GUN_DILDO2)

Model.Load(#GUN_VIBE1)

Model.Load(#GUN_VIBE2)

Model.Load(#FLOWERA)

Model.Load(#GUN_CANE)

Model.Load(#GRENADE)

Model.Load(#TEARGAS)

Model.Load(#MOLOTOV)

Model.Load(#COLT45)

Model.Load(#SILENCED)

Model.Load(#DESERT_EAGLE)

Model.Load(#CHROMEGUN)

Model.Load(#SAWNOFF)

Model.Load(#SHOTGSPA)

Model.Load(#MICRO_UZI)

Model.Load(#MP5LNG)

Model.Load(#AK47)

Model.Load(#M4)

Model.Load(#TEC9)

Model.Load(#c*ntGUN)

Model.Load(#SNIPER)

Model.Load(#ROCKETLA)

Model.Load(#HEATSEEK)

Model.Load(#FLAME)

Model.Load(#MINIGUN)

Model.Load(#SATCHEL)

Model.Load(#BOMB)

Model.Load(#SPRAYCAN)

Model.Load(#FIRE_EX)

038B: load_requested_models

 

[email protected] = 22

 

WHILE TRUE

WAIT 0

IF

PLAYER.Defined(0)

THEN

0494: get_joystick 0 direction_offset_to [email protected] [email protected] [email protected] [email protected] //RIGHT

if

[email protected] > 0

THEN

if

not [email protected] >= 42

THEN

WAIT 45

[email protected] += 1

0513: show_text_box_1number 'NUMBER' number [email protected]

ELSE

END

END

END

0494: get_joystick 0 direction_offset_to [email protected] [email protected] [email protected] [email protected] //LEFT

if

0 > [email protected]

THEN

if

[email protected] >= 1

THEN

WAIT 45

[email protected] -= 1

0513: show_text_box_1number 'NUMBER' number [email protected]

ELSE

END

END

IF

00E1: player 0 pressed_key 18 // C

THEN

if and

not [email protected] == 19

not [email protected] == 20

not [email protected] == 21

THEN

Actor.GiveWeaponAndAmmo($PLAYER_ACTOR, [email protected], 60)

WAIT 50

ELSE

END

END

END

 

 

 

 

 

 

<script data-cfasync="false" src="/cdn-cgi/scripts/ddc5a536/cloudflare-static/email-decode.min.js"></script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.