Jump to content

CommandHandler


Recommended Posts

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 

Link to comment

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) 

Link to comment

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.

Link to comment

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?

Link to comment

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 

Link to comment
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) 

Link to comment
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)

Link to comment
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).

Link to comment
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 !

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