Jump to content

Car godmode [HELP]


Price.

Recommended Posts

Posted
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?

Posted

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.

  • Moderators
Posted

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

Posted
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) 

  • Moderators
Posted
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)

  • Moderators
Posted

oh ok, then where do you set the "Stafftag" for the player ? I mean, where is/are the setElementData for "Stafftag" ?

  • Moderators
Posted

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) 

Posted

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

  • Moderators
Posted

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 !

  • Moderators
Posted

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 ...

Posted

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) 

Posted

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 ?

  • Moderators
Posted

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) 

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...