ertlflorian1 Posted January 12, 2013 Share Posted January 12, 2013 Hi the Script with the MYSQL part dont work please help me!! function oncolehit (thePlayer) pname = getPlayerName (thePlayer) if getElementType ( thePlayer ) == "player" then veh = getPedOccupiedVehicle (thePlayer) seat = getPedOccupiedVehicleSeat (thePlayer) if veh and (seat == 0) then local qh = dbQuery( handler2, "SELECT * FROM accounts WHERE Name = '"..pname.."'" ) local result, num_affected_rows, errmsg = dbPoll ( qh, -1 ) for result, row in pairs(result) do if row then if (row["Wert"] == "1") then outputChatBox ("Danke das du das Parkhaus besuchst!", thePlayer, 0,255,0) eschrankefunc () end else if getElementType ( thePlayer ) == "player" then if veh and (seat == 0) then triggerClientEvent (thePlayer, "openGUI", thePlayer, veh, pname) end end end end end end end addEventHandler ("onColShapeHit", cole, oncolehit) Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Why it doesn't work? any errors? Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 No error in debugscript 3 Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Try this: function oncolehit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" ) then local pname = getPlayerName ( thePlayer ) local veh = getPedOccupiedVehicle ( thePlayer ) local seat = getPedOccupiedVehicleSeat ( thePlayer ) if ( veh ) and ( seat == 0 ) then local qh = dbQuery ( handler2, "SELECT * FROM accounts WHERE Name = '".. pname .."'" ) local result, num_affected_rows, errmsg = dbPoll ( qh, -1 ) if ( result and type ( result ) == "table" and result [ 1 ] ) then if ( result [ 1 ] [ "Wert" ] == "1" ) then outputChatBox ( "Danke das du das Parkhaus besuchst!", thePlayer, 0, 255, 0 ) eschrankefunc ( ) else triggerClientEvent ( thePlayer, "openGUI", thePlayer, veh, pname ) end end end end end addEventHandler ( "onColShapeHit", cole, oncolehit ) Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 Error: [21:00:24] ERROR: Parkhaus\scripts\server2.lua:46: attempt to index field '?' (a nil value) Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Which line is that? because that script only has 20 lines. Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 This line if ( result [ 1 ] [ "Wert" ] == "1" ) then Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 I have tried it the it works at triggerClientEvent but not on the outputChatBox and eschrankefunc? Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Is "Wert" data set to "1"? also, seems like "result" is not returning what it should. Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 So looks it in Navicat!! Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Try this and see what it outputs to chat: function oncolehit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" ) then local pname = getPlayerName ( thePlayer ) local veh = getPedOccupiedVehicle ( thePlayer ) local seat = getPedOccupiedVehicleSeat ( thePlayer ) if ( veh ) and ( seat == 0 ) then local qh = dbQuery ( handler2, "SELECT * FROM accounts WHERE Name = '".. pname .."'" ) local result, num_affected_rows, errmsg = dbPoll ( qh, -1 ) outputChatBox ( "Rows: ".. tostring ( num_affected_rows ) ) if ( result and type ( result ) == "table" and result [ 1 ] ) then if ( result [ 1 ] [ "Wert" ] == "1" ) then outputChatBox ( "Danke das du das Parkhaus besuchst!", thePlayer, 0, 255, 0 ) eschrankefunc ( ) else triggerClientEvent ( thePlayer, "openGUI", thePlayer, veh, pname ) end end end end end addEventHandler ( "onColShapeHit", cole, oncolehit ) Link to comment
ertlflorian1 Posted January 12, 2013 Author Share Posted January 12, 2013 If "Wert" == "1" triggerClientEvent conducted and it output Rows : 1 If no entery then it only output Rows : 0 Link to comment
ertlflorian1 Posted January 14, 2013 Author Share Posted January 14, 2013 Please help me sorry for double post Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now