Jump to content

Wanted lvl little problem [HELP]


Leonard.DC

Recommended Posts

Hi, i just creating a little system that put the people to the Criminal team when then kill other players, i have a wanted level system, when i get the +3 levels, Nothing happens and no debugscript errors, why the people don't auto move to the criminal teams with the selected criminal skins? I need help with these please

Full script:

Server Side:

theSkin = {105, 106, 107, 102, 103, 104, 28, 29} 
  
function getWantedLevelAndSetCriminal (ammo, attacker, weapon, bodypart) 
local team = getPlayerTeam ( attacker ) 
local wlevel = getPlayerWantedLevel ( attacker ) 
if attacker and attacker ~= source then 
if getElementType ( attacker ) == "player" then 
if wlevel > 3 and not getTeamName( team ) == "Criminal" then 
setPlayerTeam(attacker, Criminalteam) 
outputChatBox ("You are a Dmer !", attacker, 255, 0, 0) 
setTimer (triggerClientEvent, 1000, 1, attacker, "messCrim", attacker ) 
setElementModel (attacker, theSkin[math.random(1, #theSkin)] ) 
setPlayerNametagColor ( attacker, 255, 0, 0 ) 
setTimer (triggerClientEvent, 1000, 1, attacker, "createHouseEvent", attacker ) 
end 
end 
end 
end 
addEventHandler ("onPlayerWasted", root, getWantedLevelAndSetCriminal) 

Client Side:

function setWantedDx () 
        local sWidth,sHeight = guiGetScreenSize() 
        dxDrawText("Stop Killing People Without Reason", sWidth * 0.27890625, sHeight * 0.904296875, sWidth * 0.7609375, sHeight * 0.9443359375, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", false, false, true, false, false) 
        dxDrawText("Stop Killing People Without Reason", sWidth * 0.27890625, sHeight * 0.90234375, sWidth * 0.7609375, sHeight * 0.9423828125, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", false, false, true, false, false) 
        dxDrawText("Stop Killing People Without Reason", sWidth * 0.27734375, sHeight * 0.904296875, sWidth * 0.759375, sHeight * 0.9443359375, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", false, false, true, false, false) 
        dxDrawText("Stop Killing People Without Reason", sWidth * 0.27734375, sHeight * 0.90234375, sWidth * 0.759375, sHeight * 0.9423828125, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", false, false, true, false, false) 
        dxDrawText("Stop Killing People Without Reason", sWidth * 0.278125, sHeight * 0.9033203125, sWidth * 0.76015625, sHeight * 0.943359375, tocolor(255, 0, 0, 255), 1.00, "pricedown", "center", "center", false, false, true, false, false) 
    end 
  
function setWanted () 
    addEventHandler("onClientRender",getRootElement(),setWantedDx) 
    playSound ("fail.mp3") 
    setTimer(function() removeEventHandler("onClientRender",getRootElement(),setWantedDx) end,7000,1) 
    end 
    addEvent ("messCrim", true) 
    addEventHandler ("messCrim", root, setWanted) 

Link to comment
  
theSkin = {105, 106, 107, 102, 103, 104, 28, 29} 
team = createTeam( "Criminal" , 255 , 0 , 0 ) 
function getWantedLevelAndSetCriminal (ammo, attacker, weapon, bodypart) 
local team = getPlayerTeam ( attacker ) 
local wlevel = getPlayerWantedLevel ( attacker ) 
if attacker and attacker ~= source then 
if getElementType ( attacker ) == "player" then 
if wlevel > 3 and not getTeamName( team ) == "Criminal" then 
setPlayerTeam(attacker, team) 
outputChatBox ("You are a Dmer !", attacker, 255, 0, 0) 
setTimer (triggerClientEvent, 1000, 1, attacker, "messCrim", attacker ) 
setElementModel (attacker, theSkin[math.random(1, #theSkin)] ) 
setPlayerNametagColor ( attacker, 255, 0, 0 ) 
setTimer (triggerClientEvent, 1000, 1, attacker, "createHouseEvent", attacker ) 
end 
end 
end 
end 
addEventHandler ("onPlayerWasted", root, getWantedLevelAndSetCriminal) 
  

Link to comment
  
theSkin = {105, 106, 107, 102, 103, 104, 28, 29} 
team = createTeam( "Criminal" , 255 , 0 , 0 ) 
function getWantedLevelAndSetCriminal (ammo, attacker, weapon, bodypart) 
local team = getPlayerTeam ( attacker ) 
local wlevel = getPlayerWantedLevel ( attacker ) 
if attacker and attacker ~= source then 
if getElementType ( attacker ) == "player" then 
if wlevel > 3 and not getTeamName( team ) == "Criminal" then 
setPlayerTeam(attacker, team) 
outputChatBox ("You are a Dmer !", attacker, 255, 0, 0) 
setTimer (triggerClientEvent, 1000, 1, attacker, "messCrim", attacker ) 
setElementModel (attacker, theSkin[math.random(1, #theSkin)] ) 
setPlayerNametagColor ( attacker, 255, 0, 0 ) 
setTimer (triggerClientEvent, 1000, 1, attacker, "createHouseEvent", attacker ) 
end 
end 
end 
end 
addEventHandler ("onPlayerWasted", root, getWantedLevelAndSetCriminal) 
  

The team criminal alredy exist in my script, i forgot to put it in the lua code sorry, but the team is alredy putted in the script, and it doesn't work

Link to comment

This won't work anubav since you're defining team twice.

  
theSkin = {105, 106, 107, 102, 103, 104, 28, 29} 
local team = createTeam( "Criminal" , 255 , 0 , 0 ) or getTeamFromName ( "Criminal" ) 
  
function getWantedLevelAndSetCriminal (ammo, attacker, weapon, bodypart) 
local pteam = getPlayerTeam ( attacker ) 
local wlevel = getPlayerWantedLevel ( attacker ) 
if attacker and attacker ~= source then 
if getElementType ( attacker ) == "player" then 
if wlevel > 3 and not getTeamName( pteam ) == "Criminal" then 
setPlayerTeam(attacker, team) 
outputChatBox ("You are a Dmer !", attacker, 255, 0, 0) 
setTimer (triggerClientEvent, 1000, 1, attacker, "messCrim", attacker ) 
setElementModel (attacker, theSkin[math.random(1, #theSkin)] ) 
setPlayerNametagColor ( attacker, 255, 0, 0 ) 
setTimer (triggerClientEvent, 1000, 1, attacker, "createHouseEvent", attacker ) 
end 
end 
end 
end 
addEventHandler ("onPlayerWasted", root, getWantedLevelAndSetCriminal ) 

Link to comment
  • Moderators

Well, I can't see the problem in your script. It should work.

Be sure that this script is in your meta.xml and as server script.

Then don't be afraid of using a lot of outputChatBox do debug it. I usually put an output when I enter in function, an if statement, a loop etc and 1 at the end of the function. You should then be able to see in the chatbox where the server is going in your function and where it isn't going.

Let us know if you can find it the problem this way. If you still don't see the problem, then post your code again with the ouputChatBox functions and tell us which one are working (I mean which ones really print their message into the chat).

EDIT: And hummm where do you use setPlayerWantedLevel to increment his wanted level ??

Link to comment
Well, I can't see the problem in your script. It should work.

Be sure that this script is in your meta.xml and as server script.

Then don't be afraid of using a lot of outputChatBox do debug it. I usually put an output when I enter in function, an if statement, a loop etc and 1 at the end of the function. You should then be able to see in the chatbox where the server is going in your function and where it isn't going.

Let us know if you can find it the problem this way. If you still don't see the problem, then post your code again with the ouputChatBox functions and tell us which one are working (I mean which ones really print their message into the chat).

EDIT: And hummm where do you use setPlayerWantedLevel to increment his wanted level ??

As i say i have my wanted level system, but i don't post it here because it is not necesary for this problem, And yes, All the script are indicated in the meta file

Link to comment
  • Moderators

Well, I didn't ask you to put your wanted level system, I just wanted to see if you have at least 5 stars to make it work.

But I asked you to put some outputChatBox functions in your getWantedLevelAndSetCriminal to see where the server was going and where it wasn't.

I won't reapeat a third time. It's part of the debugging process, and it has to be done by yourself before asking here.

The problem is simple: My code isn't throwing any error but still doesn't work. So there is only two possibilities which are:

1 - The getWantedLevelAndSetCriminal is never called for some reason*

2 - There is an if statement that isn't verified (I mean that the condition isn't ok for the code to go inside)

*some reason: This reason can be:

1 - The script file isn't in the meta or has the wrong type (client/server)

2 - The script contains error (like a missing end, parenthesis, comma, etc) => It should be visible in debugscript 3 (and on the server console since it's a server script) at the resource starting time.

3 - Another resource/script is cancelling the event you are using ("onPlayerWasted")

That's all the possibilities I can see so far. And all of them can be verified by using outputChatBox functions at the right place.

Link to comment
Well, I didn't ask you to put your wanted level system, I just wanted to see if you have at least 5 stars to make it work.

But I asked you to put some outputChatBox functions in your getWantedLevelAndSetCriminal to see where the server was going and where it wasn't.

I won't reapeat a third time. It's part of the debugging process, and it has to be done by yourself before asking here.

The problem is simple: My code isn't throwing any error but still doesn't work. So there is only two possibilities which are:

1 - The getWantedLevelAndSetCriminal is never called for some reason*

2 - There is an if statement that isn't verified (I mean that the condition isn't ok for the code to go inside)

*some reason: This reason can be:

1 - The script file isn't in the meta or has the wrong type (client/server)

2 - The script contains error (like a missing end, parenthesis, comma, etc) => It should be visible in debugscript 3 (and on the server console since it's a server script) at the resource starting time.

3 - Another resource/script is cancelling the event you are using ("onPlayerWasted")

That's all the possibilities I can see so far. And all of them can be verified by using outputChatBox functions at the right place.

Yep man no problem, I know what do you want to see, I will take 2 guys from my server to test it in a hamachi, Regards and see you later i will post if there is a problem

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