Jump to content

Car godmode [HELP]


Price.

Recommended Posts

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

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

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

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

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

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

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