Deep thinker Posted November 17, 2016 Share Posted November 17, 2016 (edited) hello i have a script which is depending on some kind of vip system but it's bugged because there is something wrong in the compare in the line "7" which is a laser script. local laserColor = {[2]={255, 0, 0}, [3]={255, 100, 0}} addCommandHandler("laser", function (thePlayer) if not exports["(T-RPG)VIP"]:isPlayerVIP(getAccountName(getPlayerAccount(thePlayer))) then return end local vip = exports["(T-RPG)VIP"]:isPlayerVIP(thePlayer) if vip > 1 then return end if getElementData(thePlayer, "laser.on") then lState="Disabled" r,g,b=unpack(laserColor[vip]) setElementData(thePlayer, "laser.on", false) else lState="Enabled" r,g,b=unpack(laserColor[vip]) setElementData(thePlayer, "laser.on", true) end setElementData(thePlayer, "laser.aim", false) exports["(T-RPG)Info"]:sendMessage(thePlayer,"Laser: The laser is now ".. lState ..".",r,g,b) end) Edited November 17, 2016 by ProMax Link to comment
LoPollo Posted November 17, 2016 Share Posted November 17, 2016 Probably exports["(T-RPG)VIP"]:isPlayerVIP(thePlayer) returns a boolean value, and you can't compare ( > ) a boolean with 1 (a number) It would be helpful if you posted the error you receive, but if i'm right it should be something like "cannot compare boolean with number". If i'm wrong then post more info about the problem, starting from the error Link to comment
Deep thinker Posted November 18, 2016 Author Share Posted November 18, 2016 i think the bug is in the compare only Link to comment
LoPollo Posted November 18, 2016 Share Posted November 18, 2016 I think it too but just in case there's more... also the advice is still valid, next time you ask for help copy and paste the error if present, and if not present say there's not. If you don't say anything we don't know if you are omitting or there's nothing to say about it cause there's no error. Link to comment
Deep thinker Posted November 19, 2016 Author Share Posted November 19, 2016 19 hours ago, LoPollo said: I think it too but just in case there's more... also the advice is still valid, next time you ask for help copy and paste the error if present, and if not present say there's not. If you don't say anything we don't know if you are omitting or there's nothing to say about it cause there's no error. actually i would like to thank you for the advice ,i was just copy and paste the full script for 1 point which is that i think that would help the supporter ,but we went away from the error my only question is : can you fix it ? also i have a secondary question out of the subject how can i make the weapon stop shooting it's own bullets .the weapon id is 42 which is Fire Extinguisher i want it to stop showing that smoke ,and thank you again also i would like to say that you gained me as a fan Link to comment
LoPollo Posted November 19, 2016 Share Posted November 19, 2016 (edited) The (untested) fixed script is here, but make sure you understand the fix otherwise next time you will have to start from 0 with a similar problem Note that i'm assuming that isPlayerVIP returns a boolean since you didn't negate it when i said it, but following the logic that's how it should be local laserColor = { [true]={255, 0, 0}, [false]={255, 100, 0} } addCommandHandler("laser", function (thePlayer) if not exports["(T-RPG)VIP"]:isPlayerVIP(getAccountName(getPlayerAccount(thePlayer))) then return end local isVip = exports["(T-RPG)VIP"]:isPlayerVIP(thePlayer) setElementData( thePlayer, "laser.on", not getElementData( thePlayer, "laser.on" ) ) setElementData(thePlayer, "laser.aim", false) exports["(T-RPG)Info"]:sendMessage( thePlayer, "Laser: the laser is now ".. ( getElementData( thePlayer, "laser.on" ) and "enabled" or "disabled") ..".", unpack(laserColor[isVip])) end ) I highlight it's untested, tell us if it works if you have time. 1 hour ago, ProMax said: how can i make the weapon stop shooting it's own bullets .the weapon id is 42 which is Fire Extinguisher i want it to stop showing that smoke I'm not sure if i understand: do you mean "disable" that weapon? so even if you have fire extinguisher you can't shoot with it? If so you can use these: --server event "onPlayerWeaponSwitch" --client event "onClientPlayerWeaponSwitch" toggleControl --control name: "fire" Edited November 19, 2016 by LoPollo Link to comment
Deep thinker Posted November 19, 2016 Author Share Posted November 19, 2016 1 minute ago, LoPollo said: I'm not sure if i understand: do you mean "disable" that weapon? so even if you have fire extinguisher you can't shoot with it? yeah Link to comment
LoPollo Posted November 19, 2016 Share Posted November 19, 2016 (edited) i edited the post above for the functions you can use to solve that problem. if the current weapon is 42 toggle the control "fire" to false if the previous weapon is 42 toggle the control "fire" to true EDIT: keep in mind that usign the client side event will not give you the weapon ID, but the slot. Use getPedWeapon to retrieve the weapon ID knowing the slot Edited November 19, 2016 by LoPollo 1 Link to comment
Deep thinker Posted November 19, 2016 Author Share Posted November 19, 2016 41 minutes ago, LoPollo said: i edited the post above for the functions you can use to solve that problem. if the current weapon is 42 toggle the control "fire" to false if the previous weapon is 42 toggle the control "fire" to true EDIT: keep in mind that usign the client side event will not give you the weapon ID, but the slot. Use getPedWeapon to retrieve the weapon ID knowing the slot thank you .the laser script worked and i scripted the fire extinguisher script but i have 1 more question .i want to make a script which makes the nightstick only for teams Police,SWAT,Military. i need to know what functions to use Link to comment
iPrestege Posted November 19, 2016 Share Posted November 19, 2016 12 minutes ago, ProMax said: thank you .the laser script worked and i scripted the fire extinguisher script but i have 1 more question .i want to make a script which makes the nightstick only for teams Police,SWAT,Military. i need to know what functions to use addEventHandler ( 'onClientPlayerWeaponSwitch' ) getPedWeapon getPlayerTeam getTeamFromName cancelEvent Link to comment
Deep thinker Posted November 19, 2016 Author Share Posted November 19, 2016 5 minutes ago, iPrestege said: getPedWeapon should i use this with it as the wiki said getRandomPlayer Link to comment
LoPollo Posted November 19, 2016 Share Posted November 19, 2016 (edited) but cancelling the weapon switch will also cause the inability to reach the other weapons "scrolling" in that direction I would suggest replacing the cancelEvent with a setPedWeaponSlot to simply let "skipping" the weapon instead of blocking... that will require some work through 11 minutes ago, ProMax said: should i use this with it as the wiki said getRandomPlayer No don't worry, the wiki example was using it because the example outputs the weapon a random player is holding. Edited November 19, 2016 by LoPollo Link to comment
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