Jump to content

server triggered clientside event but event is not added


nikitafloy

Recommended Posts

server triggered clientside event <...>, but event is not added.

Server

        if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( thePlayer )), aclGetGroup ( 'Security' ) ) then 
            i=i+1 
            local players = getElementsByType ( "player" ) 
                for _, GlDetect in ipairs( players ) do 
                    if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( GlDetect )), aclGetGroup ( 'GlPolice' ) ) then 
                        GlPolicePlayer = GlDetect 
                            if GlPolicePlayer then 
                                k = 55000*i 
                                if getPlayerMoney(GlPolicePlayer) >= k then 
                                    triggerClientEvent('payForJob', getRootElement(), client, k) 
                                else 
                                    outputChatBox( 'Ошибка выплат: У главного нет денег.1', root, 255, 0, 0 ) 
                                end 
                            end 
                    end 
                end 
                if not GlPolicePlayer then 
                    local nowMoney = tonumber(getElementData(getRootElement(), "funmodev2-money-GlPolice")) 
                    k = 55000*i 
                    if nowMoney >= k then 
                        givePlayerMoney( thePlayer, 55000 ) 
                        setElementData(getRootElement(), 'funmodev2-money-GlPolice', tonumber(getElementData(getRootElement(), "funmodev2-money-GlPolice"))-55000) 
                    end 
                end 
        end 
  

Client:

function payJob(player,k) 
    takePlayerMoney( player, k ) 
    local players = getElementsByType ( "player" ) 
    for theKey, thePlayer in ipairs( players ) do 
        if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( thePlayer )), aclGetGroup ( "Security" ) ) then 
            givePlayerMoney( thePlayer, 55000 ) 
        end 
    end 
end 
addEvent( "payForJob", true ) 
addEventHandler( "payForJob", getRootElement(), payJob ) 

Link to comment

Check server-side if they are in that group , if so --> trigger to the client.

But it doesn't make sense since your using givePlayerMoney client-side.

The money won't added server-side.

So better use it in server-sided file.

Using this function client side (not recommended) will not change a players money server side
Link to comment
Check server-side if they are in that group , if so --> trigger to the client.

But it doesn't make sense since your using givePlayerMoney client-side.

The money won't added server-side.

So better use it in server-sided file.

Using this function client side (not recommended) will not change a players money server side

That damn, sure! Thank you, I'll go to sleep.

Link to comment

In this case you should run this payment system on the server completely as the others described. The reason for your error however is because the server trigger the client event when the resource is started, at that moment, none of the clients has finished their downloads of this resource.

Link to comment
In this case you should run this payment system on the server completely as the others described. The reason for your error however is because the server trigger the client event when the resource is started, at that moment, none of the clients has finished their downloads of this resource.

Yes, yes, I came to his senses. Done, everything works, all thanks! :))

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