Jump to content

CommandHandler


Recommended Posts

Posted
civilian = createTeam("Civilian Workers",255,255,0) 
function Civilian (source) 
local civteam = getTeamFromName("Civilian Workers") 
local playerTeam = getPlayerTeam ( source ) 
local wantedLevel = getPlayerWantedLevel (source) 
if playerTeam == civteam then 
outputChatBox("You are already on Civilian team",source,255,0,0) return end 
    if wantedLevel == 0 then 
        veh = isPedInVehicle(source) 
        if (veh) then 
        outputChatBox("You are on vehicle",source,255,0,0) 
        return end 
        outputChatBox("You are now a Civilian",source,0,255,0) 
        setPlayerTeam(source,civilian) 
    elseif wantedLevel > 0 then 
        outputChatBox("You are wanted",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

What did I miss here? I have command /civilian. The problem is that all the option I tried using /civilian when wanted, inside a car or just on the ground. It gives only one output the

You are wanted 

Posted

What did I miss here? I have command /civilian. The problem is that all the option I tried using /civilian when wanted, inside a car or just on the ground. It gives only one output the

You are wanted 

  
local wantedLevel = getPlayerWantedLevel (source) 
if playerTeam == civteam then 
outputChatBox("You are already on Civilian team",source,255,0,0) return end 
    if wantedLevel == 0 then 
        veh = isPedInVehicle(source) 
        if (veh) then 
        outputChatBox("You are on vehicle",source,255,0,0) 
        return end 
        outputChatBox("You are now a Civilian",source,0,255,0) 
        setPlayerTeam(source,civilian) 
    elseif wantedLevel > 0 then 
        outputChatBox("You are wanted",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

Posted

What did I miss here? I have command /civilian. The problem is that all the option I tried using /civilian when wanted, inside a car or just on the ground. It gives only one output the

You are wanted 

  
local wantedLevel = getPlayerWantedLevel (source) 
if playerTeam == civteam then 
outputChatBox("You are already on Civilian team",source,255,0,0) return end 
    if wantedLevel == 0 then 
        veh = isPedInVehicle(source) 
        if (veh) then 
        outputChatBox("You are on vehicle",source,255,0,0) 
        return end 
        outputChatBox("You are now a Civilian",source,0,255,0) 
        setPlayerTeam(source,civilian) 
    elseif wantedLevel > 0 then 
        outputChatBox("You are wanted",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

Please dont event reply if you are not going to change something.

Posted

Buddy, how can I change something when there is no need for change? I highlighted what you wrote, you said you tried the command while you were wanted, that's why it always outputs "You are wanted".

Posted

Try this:

  
civilian = createTeam("Civilian Workers",255,255,0) 
function Civilian (source) 
local civteam = getTeamFromName("Civilian Workers") 
local playerTeam = getPlayerTeam ( source ) 
setPlayerWantedLevel(source, 0) 
local wantedLevel = getPlayerWantedLevel (source) 
if playerTeam == civteam then 
outputChatBox("You are already on Civilian team",source,255,0,0) return end 
    if wantedLevel == 0 then 
        veh = isPedInVehicle(source) 
        if (veh) then 
        outputChatBox("You are on vehicle",source,255,0,0) 
        return end 
        outputChatBox("You are now a Civilian",source,0,255,0) 
        setPlayerTeam(source,civilian) 
    elseif wantedLevel > 0 then 
        outputChatBox("You are wanted",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 
  

Tell me if it still outputs the same. Also, are you getting any errors in the debug?

Posted

You obviously don't know how to check if your code is legit and working, and if you're not cooperative I'm not going to bother helping you. Good luck with the code.

Posted

You dont event know what you are doing too. I am just asking my error why does it return only one (You are wanted) yet you are adding non sense codes like that setting the wantedlevel of the player.

Posted

I have changed the codes and now I only get one error now.

civilian = createTeam("Civilian Workers",255,255,0) 
function Civilian (source) 
civteam = getTeamFromName("Civilian Workers") 
playerTeam = getPlayerTeam(source) 
wantedLevel = getPlayerWantedLevel (source) 
veh = isPedInVehicle(source) 
    if not (playerTeam == civteam) then 
        if wantedLevel == 0 then 
            if (veh) then 
            outputChatBox("You are on vehicle",source,255,0,0) 
            else 
            outputChatBox("You are now a Civilian",source,0,255,0) 
            setPlayerTeam(source,civilian) 
            end 
        elseif wantedLevel > 0 then 
            outputChatBox("You are wanted",source,255,0,0) 
        end 
    else 
    outputChatBox("You are already in Civilian Team",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

You are now a Civilian 

and

You are already in Civilian Team 

is now working

But when I am on a vehicle and not wanted. It gives me this,

You are wanted 

Posted
local civilian = createTeam("Civilian Workers",255,255,0) 
  
function Civilian (player) 
    local playerTeam = getPlayerTeam(player) 
    local wantedLevel = getPlayerWantedLevel (player) or 0 
    if not (playerTeam == civilian) then 
        if wantedLevel == 0 then 
            if isPedInVehicle(player) then 
                outputChatBox("You can't use this command when inside a vehicle",player,255,0,0) 
                return  
            end  
            outputChatBox("You are now a Civilian",player,0,255,0) 
            setPlayerTeam(player,civilian) 
        else 
            outputChatBox("You are wanted",player,255,0,0) 
        end 
    else 
        outputChatBox("You are already in Civilian Team",player,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

Posted
local civilian = createTeam("Civilian Workers",255,255,0) 
  
function Civilian (player) 
    local playerTeam = getPlayerTeam(player) 
    local wantedLevel = getPlayerWantedLevel (player) or 0 
    if not (playerTeam == civilian) then 
        if wantedLevel == 0 then 
            if isPedInVehicle(player) then 
                outputChatBox("You can't use this command when inside a vehicle",player,255,0,0) 
                return  
            end  
            outputChatBox("You are now a Civilian",player,0,255,0) 
            setPlayerTeam(player,civilian) 
        else 
            outputChatBox("You are wanted",player,255,0,0) 
        end 
    else 
        outputChatBox("You are already in Civilian Team",player,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

Now all option became (You are wanted)

Posted
civilian = createTeam("Civilian Workers",255,255,0) 
function Civilian (source) 
civteam = getTeamFromName("Civilian Workers") 
playerTeam = getPlayerTeam(source) 
wantedLevel = getPlayerWantedLevel (source) 
veh = isPedInVehicle(source) 
    if not (playerTeam == civteam) then 
        if wantedLevel == 0 then 
            if (veh) then 
            outputChatBox("You are on vehicle",source,255,0,0) 
            else 
            outputChatBox("You are now a Civilian",source,0,255,0) 
            setPlayerTeam(source,civilian) 
            end 
        elseif wantedLevel > 0 then 
            outputChatBox("You are wanted",source,255,0,0) 
        end 
    else 
    outputChatBox("You are already in Civilian Team",source,255,0,0) 
    end 
end 
addCommandHandler("civilian",Civilian) 

Is like If team is not Civilian Workers

>if wanted = 0 > if on vehicle > output(In vehicle) 
>if wanted = 0 > if not on vehicle > output(You are now Civ) 
>if wanted > 0 > if on vehicle/ not on vehicle > You are wanted. 
Else If on Civilian 
>output (You are already Civs.) 
  

My script is working if not wanted it makes me Civilian and when trying to execute it again also work (You are already Civ.)

the problem is that If I get on vehicle and not wanted, it shows me (You are wanted) rather than (You are in vehicle).

Posted
You're insane then, unless you have a wanted level that should not appear, I checked every bit of this code for what would be causing it, nothing.

Thank you, Jesus...

Posted
You're insane then, unless you have a wanted level that should not appear, I checked every bit of this code for what would be causing it, nothing.

Thank you, Jesus...

Adding the script with setPlayerWanteLevel to 0 even if not asked to. That is why I have the *IF* argument of wantedLevel ==0 and wantedLevel > 0. Jesus !

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