Jump to content

TriggerServerEvent


BriGhtx3

Recommended Posts

Client

local geld = tonumber(guiGetText(hoeheText)) 
if (geld > 4999) and (geld < 100001) then 
local zinssatz = tonumber(math.ceil(((geld/551.6*0.7)+0.3)/10)) 
triggerServerEvent( "kreditabsenden", getLocalPlayer(), geld, zinssatz) 
outputChatBox("bearbeite") 

Server

  
function submitKredit(player, geld, zinssatz) 
    local result = mysql_query(handler, "INSERT INTO kredit (Person, Kredit, Zinssatz, Restgeld) VALUES ('"..getPlayerName(source).."', '"..geld.."', '"..zinssatz.."', '"..geld.."')") 
    if( not result) then 
        outputDebugString("Error executing the query: (" .. mysql_errno(handler) .. ") " .. mysql_error(handler)) 
    else 
        mysql_free_result(result) 
    end 
    outputChatBox("Kredit erfolgreich beantragt! Schaue nun auf deinem Konto nach!", getPlayerName(source), 255,0,0) 
    vioSetElementData ( source, "bankmoney", vioGetElementData ( source, "bankmoney" ) + geld ) 
    end 
    addEventHandler("kreditabsenden", getRootElement(), submitKredit) 
    addEvent("kreditabsenden", true) 

When I press on the button, "bearbeite" shows, which means that the client function should be right. Just the server event, ist not triggered.

There aren't any errors outputted, when I type debugscript 3.

You should know that, vioSet/GetElementData is a global variable.

The text in the server part isn't outputted whether, in the database.

Link to comment

function submitKredit(player, geld, zinssatz)

should be

function submitKredit(geld, zinssatz)

and addEvent("kreditabsenden", true) should be before addEventHandler I think. (swap the lines)

edit:

and in the outputChatBox, instead of getPlayerName(source) use source (no need to get the name)

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