Jump to content

onClientPedWasted


Drakath

Recommended Posts

Posted (edited)

What this script supose to do?

function makeitgoup(killer,weapon,bodypart) 
if killer then 
local statx=getPedStat(killer,63) 
 if (statx > 2)then 
triggerClientEvent("statsup22",killer) 
setPedStat(killer,63,0) 
else 
setPedStat(killer,63,statx  +1) 
end 
end 
end 
addEvent("stats",true) 
addEventHandler("stats",getRootElement, makeItGoUp) 

Edited by Guest
Posted (edited)
***** 

It has to be: "triggerEvent("statsup22",killer)" because statsup22 is in serverside.

But it still doesn't work.

Edited by Guest
Posted

Try my script :|

Server side:

Stats = { 
    [22] = { 69 }; 
    [23] = { 70 }; 
    [24] = { 71 }; 
    [25] = { 72 }; 
    [26] = { 73 }; 
    [27] = { 74 }; 
    [28] = { 75 }; 
    [29] = { 76 }; 
    [30] = { 77 }; 
    [31] = { 78 }; 
    [34] = { 79 }; 
}; 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( ammo, killer, weapon, bodypart ) 
        if killer then 
            if getElementType ( killer ) == "player" then 
                if killer ~= source then 
                    if Stats[tonumber(weapon)] then 
                        setPedStat ( killer, Stats[tonumber(weapon)][1], getPedStat ( killer, Stats[tonumber(weapon)][1] ) + 1 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Posted

It must be 'onClientPedWasted' because there are client-side zombies. It worked fine with server-side zombies before...

Don't worry about statsup22, it's fine.

Posted (edited)

When a zombie is dead of course. But focus on the server-side I posted. For example:

***** 

None of the outputs outputted.

Edited by Guest
Posted
Stats = { 
    [22] = { 69 }; 
    [23] = { 70 }; 
    [24] = { 71 }; 
    [25] = { 72 }; 
    [26] = { 73 }; 
    [27] = { 74 }; 
    [28] = { 75 }; 
    [29] = { 76 }; 
    [30] = { 77 }; 
    [31] = { 78 }; 
    [34] = { 79 }; 
}; 
  
addEventHandler ( "onZombieWasted", root, 
    function ( killer, weapon, bodypart ) 
        if killer then 
            if getElementType ( killer ) == "player" then 
                if killer ~= source then 
                    if Stats[tonumber(weapon)] then 
                        setPedStat ( killer, Stats[tonumber(weapon)][1], getPedStat ( killer, Stats[tonumber(weapon)][1] ) + 1 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Posted
function statsup(killer) 
    if killer and killer == localPlayer and getElementData(source, "filmbot") then 
        triggerServerEvent("stats", killer) 
   end 
end 
addEventHandler("onClientPedWasted", root, statsup) 

function makeitgoup() 
    local statx = getPedStat(source, 63) 
    if (statx > 2)then 
        triggerEvent("statsup22", source) 
        setPedStat(source, 63, 0) 
    else 
        setPedStat(source, 63, statx + 1) 
    end 
end 
addEvent("stats", true) 
addEventHandler("stats", root, makeitgoup) 

If it doesn't work, post the function that attached to the event "statsup22" and explain what is doesn't work.

Posted
Oh, server-side might be fine, but your client-side doesn't work.

Not my client-side, but your element data.

getElementData(source, "filmbot") 

Where did you set the element data?

Posted (edited)

My zombies has element data "filmbot".

My old client-side worked fine.

***** 

But the server-side doesn't.

Edited by Guest
Posted

Huh? this is the same, i only change p to killer and added a check.

Let me know what this code output.

Client Side:

function statsup(killer) 
    outputChatBox("Client Test: 1") 
    if killer and killer == localPlayer and getElementData(source, "filmbot") then 
        outputChatBox("Client Test: 2") 
        triggerServerEvent("stats", killer) 
   end 
end 
addEventHandler("onClientPedWasted", root, statsup) 

Server Side:

function makeitgoup() 
    outputChatBox("Server Test: 1") 
    local statx = getPedStat(source, 63) 
    if (statx > 2)then 
        outputChatBox("Server Test: 2") 
        triggerEvent("statsup22", source) 
        setPedStat(source, 63, 0) 
        outputChatBox("Server Test: 3") 
    else 
        outputChatBox("Server Test: 4") 
        setPedStat(source, 63, statx + 1) 
    end 
    outputChatBox("Server Test: 5") 
end 
addEvent("stats", true) 
addEventHandler("stats", root, makeitgoup) 

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