Jump to content

reload a specific weapon


icarus

Recommended Posts

Posted

I made this but for idk why it doesnt work, it doesnt even output a debugscript message, can u help ?

---Clientside 
function reloadtazerclient () 
if getPedWeapon ( getLocalPlayer())== 23 then 
triggerServerEvent ("ontazershoot", getLocalPlayer()) 
end 
end 
addEventHandler ("onClientPedWeaponFire", getRootElement(), reloadtazerclient) 
  

---Serverside 
addEvent ("ontazershoot", true) 
  
function tazershootserverside(sourcePlayer) 
reloadPedWeapon ( sourcePlayer ) 
end 
addEventHandler("ontazershoot", getRootElement(),tazershootserverside) 

(i already tryed "(source)" insted of "(sourcePlayer)", and "weapon == 23" insted of " getPedWeapon ( getLocalPlayer())== 23", and didnt work.

Posted

-- client side:

function reloadtazerclient ( weapon ) 
    if ( weapon == 23 ) then 
        triggerServerEvent ( "ontazershoot", localPlayer ) 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", localPlayer, reloadtazerclient ) 

-- server side:

function tazershootserverside ( ) 
    reloadPedWeapon ( source ) 
end 
addEvent ( "ontazershoot", true ) 
addEventHandler ( "ontazershoot", root, tazershootserverside ) 

That should work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It's actually executing the function, but seems like it doesn't reload it at all.

You can restrict the weapon clip amount to 1 with: setWeaponProperty.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

yeah lol, this must be simplier, but still cant work with it

---clientside 
function tazerreload( startedRes ) 
setWeaponProperty ( 23, "maximum_clip_ammo", 1 ) 
end 
addEventHandler( "onClientResourceStart", getLocalPlayer( ),tazerreload) 

Posted (edited)

actually, it's a resource, so try this:

---clientside 
function tazerreload( startedRes ) 
setWeaponProperty ("silenced_pistol" ,"poor", "maximum_clip_ammo", 1 ) 
end 
addEventHandler( "onResourceStart", resourceRoot,tazerreload) 

Edited by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Server:

function tazerreload( startedRes ) 
    setWeaponProperty ( 23, "poor", "maximum_clip_ammo", 1 ) 
    setWeaponProperty ( 23, "std", "maximum_clip_ammo", 1 ) 
    setWeaponProperty ( 23, "pro", "maximum_clip_ammo", 1 ) 
end 
addEventHandler( "onResourceStart", resourceRoot,tazerreload) 

2dvicdc.png2pq2asy.pnge02ykh.png2s6sv4l.png124bwvt.png

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...