Jump to content

Problem script EXP


JuniorMelo

Recommended Posts

Hello

I have a problem with this script

When the player dies in a car does not count EXP

function win(ammo, killer, weapon, bodypart) 
local killer1 = getPlayerName(killer) 
local name = getPlayerName(source) 
    if (killer and killer ~= source) then 
    if (getElementType(killer) == "vehicle") then killer = getVehicleController(killer) end 
        if (killer) then 
         triggerClientEvent(killer, "exp", getRootElement()) 
        end 
    end 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 

sorry my bad english :shock::cry:

Link to comment

Try this.

function win ( ammo, killer, weapon, bodypart ) 
    if killer then 
        if getElementType ( killer ) == "player" then 
            if killer ~= source then 
                triggerClientEvent ( killer, "exp", root ) 
            end 
        elseif getElementType ( killer ) == "vehicle" then 
            local killer = getVehicleOccupant ( killer, 0 ) 
            if killer then 
                triggerClientEvent ( killer, "exp", root ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root, win ) 

Link to comment
Try this.
function win ( ammo, killer, weapon, bodypart ) 
    if killer then 
        if getElementType ( killer ) == "player" then 
            if killer ~= source then 
                triggerClientEvent ( killer, "exp", root ) 
            end 
        elseif getElementType ( killer ) == "vehicle" then 
            local killer = getVehicleOccupant ( killer, 0 ) 
            if killer then 
                triggerClientEvent ( killer, "exp", root ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root, win ) 

sorry, is not what i wanted

when another player is in a vehicle not count EXP

function win ( ammo, killer, weapon, bodypart ) 
    if killer then 
        if getElementType ( killer ) == "player" then 
            if killer ~= source then 
                triggerClientEvent ( killer, "exp", root ) 
            end 
        elseif getElementType ( source ) == "vehicle" then 
            local source = getVehicleOccupant ( source, 0 ) 
            if source then 
                triggerClientEvent ( source, "exp", root ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root, win ) 

Link to comment
  • Moderators

Nothing is impossible, my server is already using a system that can do that or even more.

But I won't start talking about that because you simply can't use my property...

What you can try is using the event's to save the last vehicle etc.

https://wiki.multitheftauto.com/wiki/OnVehicleEnter

https://wiki.multitheftauto.com/wiki/OnVehicleExit

https://wiki.multitheftauto.com/wiki/OnVehicleExplode

If you really want to create something like that,

You have to create your own system to manage the data, you can choose for elementdata or using tables for quick data usage. If you can work with tables, use tables cause they are 1000+ times faster with data then elementdata.

Good luck cause you still have a long way to go for perfection.

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