GamerDeMTA Posted July 30, 2013 Posted July 30, 2013 This function, getWeaponAmmo I have something wrong... I put the ID of the weapon like this but it gives error, expected weappon argument 2 got number '38'. getWeaponAmmo ( 38 ) https://wiki.multitheftauto.com/wiki/getWeaponAmmo
Castillo Posted July 30, 2013 Posted July 30, 2013 getWeaponAmmo is used for custom weapons, not players. You must use: getPedWeapon getPedTotalAmmo
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 but i have a problem... I want to do it only for the weapon ID 38. and those functions are for weapon slots.
Castillo Posted July 30, 2013 Posted July 30, 2013 Use the minigun weapon slot ( get it from the wiki page ), then check if he has the minigun on the slot.
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 how to check if he has the minigun, after that?
Castillo Posted July 30, 2013 Posted July 30, 2013 getPedWeapon returns the weapon ID, just check if it's 38.
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 (edited) i tried to but i dont understand how to... could you tell me? how to do that if the weapon > 5 it goes to 1 **for set the ammo i think i must use trigger and giveweapon in serverside no?** Edited July 30, 2013 by Guest
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 function ( ) if getPedTotalAmmo ( getLocalPlayer(), 7 ) > 1 then triggerServerEvent("lol", getLocalPlayer()) end end setTimer(, 100, 0) server addEvent("lol") addEventHandler("lol", root, giveWeapon(source, 38, 1) end ) as u see it's a madness And no idea yet how to get the weapon minigun =/
Castillo Posted July 30, 2013 Posted July 30, 2013 function ( ) local weapon = getPedWeapon ( localPlayer, 7 ) if ( weapon == 38 ) then if ( getPedTotalAmmo ( localPlayer, 7 ) > 1 ) then triggerServerEvent ( "lol", localPlayer ) end end end setTimer ( , 100, 0 ) Using a timer isn't an efficient method though.
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 why not? so each 0.1 seconds it checks if you have that no?
Castillo Posted July 30, 2013 Posted July 30, 2013 You could use the onClientPlayerWeaponSwitch event instead, so when he switches to the minigun, it'll trigger.
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 ok thanks. oh and i have other doubt, what's elseif for? same as if? or it's other use?
Castillo Posted July 30, 2013 Posted July 30, 2013 Example: if ( money == 200 ) then -- Do something elseif ( money == 400 ) then -- Do something else end And you can keep using it.
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 ok oh i tried the script with onClientPlayerWeaponSwitch event instead setTimer but it says this in debug: ERROR: Client (GamerDeMTA) triggered serverside event lol, but event is not marked aas remotly triggerable
GamerDeMTA Posted July 30, 2013 Author Posted July 30, 2013 Client side addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), function ( ) local weapon = getPedWeapon ( source, 7 ) if ( weapon == 38 ) then if ( getPedTotalAmmo ( source, 7 ) > 1 ) then triggerServerEvent ( "lol", source ) end end end ) serverside addEvent("lol") addEventHandler("lol", getRootElement(), function ( ) giveWeapon ( source, 38, 1 ) end )
Castillo Posted July 30, 2013 Posted July 30, 2013 addEvent("lol") Change that to: addEvent ( "lol", true )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now