Price. Posted February 16, 2014 Share Posted February 16, 2014 function vehicleGodMod(player) if not getElementData (player,"Stafftag") >= 4 then outputChatBox("You dont have permission for this command!",player,255) return end if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) this is cargodmode script i want only L3 and above can use this command so when i added this and tested in my server gave me that error attempt to compare number with boolean, when i used it in my friend's server always tell me you dont have permission for this command! and iam L3 already, any help? Link to comment
-ffs-AbodyRulez Posted February 16, 2014 Share Posted February 16, 2014 Try this: function vehicleGodMod(player) if not tonumber(getElementData(player,"Stafftag")) >= 4 then outputChatBox("You dont have permission for this command!",player,255) else if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Make sure to be logged in. Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 same [05:55:43] ERROR: cargod\cargodmode.lua:2: attempt to compare number with boolean Link to comment
Anubhav Posted February 16, 2014 Share Posted February 16, 2014 Price . Are you sure that used setElementData ( source, "Stafftab", false) so you are getting that data? Link to comment
Karuzo Posted February 16, 2014 Share Posted February 16, 2014 How should he get the data if he sets it? Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 Haha no, you are all wrong, there is a priority problem over this line: if not getElementData (player,"Stafftag") >= 4 then Take a second to look at it. If getElementData (player,"Stafftag") returns 0, then it will result to something like this: if not 0 >= 4 then The priority is given to the not keyword and then the >= And not 0 returns true so we will end with this: if true >= 4 then And doing "not" on a number that is over 0 will returns false So if you got it, you just have to add parenthesis to fix the priority issue: if not (getElementData (player,"Stafftag") >= 4) then It should work. In the meantime, I would recommend to swap the two parts of that if else statement like this: function vehicleGodMod(player) if getElementData(player,"Stafftag") >= 4 then if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end else outputChatBox("You dont have permission for this command!",player,255) end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Regards, Citizen Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 attempt to compare number with boolean @ citizen Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 How is your code right now ? Paste it here again please. Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 function vehicleGodMod(player) if getElementData(player,"Stafftag") >= 4 then if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end else outputChatBox("You dont have permission for this command!",player,255) end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 attempt to compare number with boolean @ citizen Which line please ? (don't write the line number given by the console, just write the entire line corresponding to that line number) Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 if getElementData(player,"Stafftag") >= 4 then Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 oh ok, then where do you set the "Stafftag" for the player ? I mean, where is/are the setElementData for "Stafftag" ? Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 uhm i didnt add it yet, well can u gimme the function inside the script to test it? Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 So you were trying to get a value that you never seted ... function vehicleGodMod(player) ----- To set at login ---- setElementData(player, "Stafftag", 3) --set the data Stafftag to 3 for player -------------------------- if getElementData(player,"Stafftag") >= 3 then if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end else outputChatBox("You dont have permission for this command!",player,255) end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 uhm it works ,1st thing can i add it to 4 instead of 3? also uhm iam not in either lvl 3 or 4 or anything just Admin group and still can work with /vgod it works when iam admin i want only L3+ can do it Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 Of course, you can replace 3 to 4 ... Which level are you talking about ?! I thought you already did your level system using Stafftag to store it ! Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 well inside Stafftag there is L0 L1 L2 L3 and L4 i want it to be used for L3 + only Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 You are obviously lying, otherwise you wouldn't get that error: attempt to compare number with boolean - But I'm not lying ! - Alright, show me the setElementData that set "Stafftag" to L0 L1 L2 L3 then ... Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 i've actually fixed it, i wanted it so Special groups could do it the Lvl 3 nd L4 only so i was tryin and gave it a try and this actually worked without any errors i made L3 and L4 groups and they worked but when i made L2 or less didn't exactly how i wanted it to be! ofc with ur code it helped alot thx function vehicleGodMod(player) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("L3"),("L4")) then setElementData(player, "Stafftag", 3) if getElementData(player,"Stafftag") >= 3 then if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end else outputChatBox("You dont have permission for this command!",player,255) end end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 hey but althought when i do /vgod a lot it doesnt tell me you dont have permission for this command if iam L2 or less can u help me ? Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 Ok so next time, you will explain better. I didn't even know your wanted to use groups from ACL. So now, Stafftag is totally useless, remove it (and wtf, this code can't work, this ,("L4") comes from nowhere: function vehicleGodMod(player) local accname = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accname, aclGetGroup("L3")) or isObjectInACLGroup("user."..accname, aclGetGroup("L4")) then if (isVehicleDamageProof(getPedOccupiedVehicle(player))) then setVehicleDamageProof(getPedOccupiedVehicle(player),false) outputChatBox("Vehicle god mode disabled",player,255) else setVehicleDamageProof(getPedOccupiedVehicle(player),true) outputChatBox("Vehicle god mode enabled",player,0,255) end else outputChatBox("You dont have permission for this command!",player,255) end end addCommandHandler("vgod",vehicleGodMod) addCommandHandler("vehiclegod",vehicleGodMod) Link to comment
Price. Posted February 16, 2014 Author Share Posted February 16, 2014 thx bro really helped me! 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