Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MYSQL SETUP --
- local sql = mysql_connect('localhost', 'root', '', 'larsowitsh')
- if not sql then outputDebugString('Cant Connect to MYSQL Server!') else outputDebugString('MYSQL: Connected!') end
- -- Events
- addEvent('onAdminSavePickup', true)
- -- Functions
- addCommandHandler('createpickup',
- function(thePlayer)
- local Acc = getAccountName(getPlayerAccount(thePlayer))
- if isObjectInACLGroup('user.'..Acc, aclGetGroup("Admin")) then
- triggerClientEvent(thePlayer, 'onAdminRequestPanel', thePlayer, thePlayer)
- end
- end)
- addEventHandler('onAdminSavePickup', getRootElement(),
- function( X, Y, Z , ID, GELD, CREATOR, gMe)
- local result = mysql_query(sql,"INSERT INTO pickups (CREATOR, X,Y,Z, MODEL, GELD) VALUES ('"..CREATOR.."','"..X.."','"..Y.."','"..Z.."','"..ID.."','"..GELD.."');")
- if result then
- outputChatBox('Das Pickup wird beim naechsten Server Restart benutzbar sein!', gMe,0,125,0,false)
- triggerClientEvent(thePlayer, 'onAdminPickupSaved', gMe)
- end
- end)
- addEventHandler('onResourceStart',getResourceRootElement(getThisResource()),
- function()
- local result = mysql_query ( sql, "SELECT * FROM pickups;" )
- local dsatz
- local Anzahl = 0
- if (result) then
- dsatz = mysql_fetch_assoc( result )
- while dsatz do
- local x, y, z = dsatz['X'], dsatz['Y'], dsatz['Z']
- local geld = dsatz['GELD']
- local model = dsatz['MODEL']
- local Creator = dsatz['CREATOR']
- local SelfmadeGeldPickUp = createPickup(x,y,z, 3, model)
- setElementData(SelfmadeGeldPickUp, 'GELD', geld)
- setElementData(SelfmadeGeldPickUp, 'CREATOR', Creator)
- Anzahl = tonumber(Anzahl) + 1
- dsatz = mysql_fetch_assoc(result)
- addEventHandler('onPickupHit', SelfMadeGeldPickUp,
- function(thePlayer)
- if(getElementType(thePlayer) ~= "player") then return end
- givePlayerMoney(thePlayer, getElementData(source,'GELD'))
- outputChatBox('Du hast einen versteckten Aktenkoffer gefunden!', thePlayer,125,125,0,false)
- destroyElement(SelfmadeGeldPickUp)
- end)
- end
- outputDebugString("Es wurden "..tonumber(Anzahl).." Pickups erstellt")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment