xScander Posted August 6, 2014 Share Posted August 6, 2014 Hello, I tried to make a Moneytruck for my Reallife Server with the Los Angeles Reallife Script. But if i drive through the marker, the truck doesn't disappear and you donn't get money. I have to files. The SFPD_Deliver.lua and the moneytruck.lua. I can't find the failure and i got only these errors: [2014-08-06 20:03:42] WARNING: script/jobs/robs/moneytruck.lua:164: Bad argument @ 'setElementPosition' [Expected element at argument 1] [2014-08-06 20:26:24] ERROR: script/jobs/robs/SFPD_deliver.lua:23: attempt to concatenate local 'player' (a userdata value) [2014-08-06 20:22:04] ERROR: script/jobs/robs/moneytruck.lua:86: attempt to concatenate global 'kokstruckcount' (a nil value) Moneytruck.lua : --]]moneyTRUCK[[-- MoneyTruck = createBlip (-1590.4000244141, 717.40002441406, 8.1000003814697, 42, 2, 255, 0, 0, 255, 0, 200, getRootElement() ) local moneyTruckEntrance = createMarker (-1590.4000244141, 717.40002441406, 8.1000003814697, "cylinder", 2, 255, 0, 0, 150) function moneyTruckEntrance_func ( player, dim ) if getElementType(player) == "player" and (dim) then if isPedInVehicle ( player ) == false then if isArmy(player) or isFBI(player) or isOnStateDuty(player) then outputChatBox ( "[iNFO]: Verwende /moneytruck [sUMME] um einen Truck zu starten! Maximal 20.000 Euro Maximal und 1 Truck pro Stunde!", player, 0, 200, 200 ) else outputChatBox ( "Du bist kein Staatsbeamter im Dienst!", player, 200, 0, 0 ) end end end end addEventHandler ( "onMarkerHit", moneyTruckEntrance, moneyTruckEntrance_func ) function MoneyTruck_func ( player, cmd, money ) if not money then infobox ( player, "\n\nVerwende: /moneytruck [sUMME]", 5000, 125, 0, 0 ) else if isArmy ( player ) or isFBI ( player ) or isOnStateDuty ( player ) then moneynumber = tonumber(money) moneyprice = moneynumber * 0 local x, y, z = getElementPosition ( player ) if getDistanceBetweenPoints3D ( -1590.4000244141, 717.40002441406, 8.1000003814697, x, y, z ) < 5 then if moneytransport == nil then moneytransport = 0 end if moneytransport == 0 then if (20000 >= moneynumber) and (moneynumber > 0) then if laGetElementData ( player, "money" ) >= moneyprice then laSetElementData ( player, "money", laGetElementData(player,"money")-moneyprice ) takePlayerMoney ( player, moneyprice ) triggerClientEvent ( player, "HudEinblendenMoney", getRootElement() ) loadMoneyTruck ( player, moneynumber, moneyprice ) else triggerClientEvent ( player, "infobox_start", getRootElement(), "\n\nDu hast zu wenig Geld!", 7000, 125, 0, 0 ) end else triggerClientEvent ( player, "infobox_start", getRootElement(), "\n\nVerwende: /moneytruck [sUMME]\n(maximal 20000 Euro!)!", 7000, 125, 0, 0 ) end else triggerClientEvent ( player, "infobox_start", getRootElement(), "\n\nEs ist bereits ein\nGeldtruck unterwegs!", 7000, 125, 0, 0 ) end else triggerClientEvent ( player, "infobox_start", getRootElement(), "\n\nDu bist zu\nweit weg!", 7000, 125, 0, 0 ) end else triggerClientEvent ( player, "infobox_start", getRootElement(), "\n\nDu bist kein Staatsbeamter im Dienst!", 7000, 125, 0, 0 ) end end end addCommandHandler ( "moneytruck", MoneyTruck_func ) function loadMoneyTruck ( player, money, moneyprice ) moneyanzahl = moneynumber moneypreis = moneyprice local msg = "[LEGAL]: Ein Geldtruck wurde beladen!" sendMSGForFaction ( msg, 1, 200, 0, 0 ) sendMSGForFaction ( msg, 2, 200, 200, 0 ) sendMSGForFaction ( msg, 3, 200, 200, 0 ) sendMSGForFaction ( msg, 5, 200, 200, 0 ) sendMSGForFaction ( msg, 6, 200, 0, 0 ) sendMSGForFaction ( msg, 7, 200, 200, 0 ) sendMSGForFaction ( msg, 8, 200, 0, 0 ) sendMSGForFaction ( msg, 9, 0, 150, 0 ) sendMSGForFaction ( msg, 10, 200, 200, 0 ) outputLog ( "[GELDTRUCK]: "..getPlayerName ( player ).." hat einen Geldtruck gestartet!", "bad" ) if MoneyTruckcount == nil then MoneyTruckcount = 1 else MoneyTruckcount = MoneyTruckcount + 1 end moneytransport = 1 _G["MoneyTruck"..MoneyTruckcount] = createVehicle ( 609, -1607.4000244141, 742, -5, 0, 0, 88, "money" ) setVehiclePaintjob ( _G["MoneyTruck"..MoneyTruckcount], 2 ) setVehicleColor ( _G["MoneyTruck"..MoneyTruckcount], 86, 86, 0, 0 ) setElementHealth ( _G["MoneyTruck"..MoneyTruckcount], 1500 ) laSetElementData ( _G["MoneyTruck"..MoneyTruckcount], "money", moneyanzahl ) laSetElementData ( _G["MoneyTruck"..MoneyTruckcount], "kosten", moneypreis ) laSetElementData ( _G["MoneyTruck"..MoneyTruckcount], "MoneyTruck", 1 ) warpPedIntoVehicle ( player, _G["MoneyTruck"..MoneyTruckcount] ) outputChatBox ( "[AUFGABE]: Bringe nun den Geldtruck zur PD-Garage in LS!", player, 0, 100, 200 ) setElementVisibleTo ( SFPDDeliver, player, true ) setElementVisibleTo ( SFPDDeliverBlip, player, true ) laSetElementData ( _G["MoneyTruck"..kokstruckcount], "moneycar", 1 ) end function vehicleEnterMoneyTruck (veh) local driver = source if laGetElementData ( veh, "MoneyTruck" ) == 1 then if laGetElementData ( driver, "fraktion" ) == 2 then setElementVisibleTo ( CamorraDeliver, driver, true ) setElementVisibleTo ( CamorraDeliverBlip, driver, true ) end if laGetElementData ( driver, "fraktion" ) == 3 then setElementVisibleTo ( YakuzaDeliver, driver, true ) setElementVisibleTo ( YakuzaDeliverBlip, driver, true ) end if laGetElementData ( driver, "fraktion" ) == 7 then setElementVisibleTo ( SurenosDeliver, driver, true ) setElementVisibleTo ( SurenosDeliverBlip, driver, true ) end if laGetElementData ( driver, "fraktion" ) == 9 then setElementVisibleTo ( ComptonDeliver, driver, true ) setElementVisibleTo ( ComptonDeliverBlip, driver, true ) end if laGetElementData ( driver, "fraktion" ) == 10 then setElementVisibleTo ( WattsDeliver, driver, true ) setElementVisibleTo ( WattsDeliverBlip, driver, true ) end if laGetElementData ( driver, "fraktion" ) == 1 then setElementVisibleTo ( SFPDDeliver, driver, true ) setElementVisibleTo ( SFPDDeliverBlip, driver, true ) end end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), vehicleEnterMoneyTruck ) function vehicleExitMoneyTruck (veh) if laGetElementData ( veh, "MoneyTruck" ) == 1 then if laGetElementData ( source, "fraktion" ) == 2 then setElementVisibleTo ( CamorraDeliver, source, false ) setElementVisibleTo ( CamorraDeliverBlip, source, false ) end if laGetElementData ( source, "fraktion" ) == 3 then setElementVisibleTo ( YakuzaDeliver, source, false ) setElementVisibleTo ( YakuzaDeliverBlip, source, false ) end if laGetElementData ( source, "fraktion" ) == 7 then setElementVisibleTo ( SurenosDeliver, source, false ) setElementVisibleTo ( SurenosDeliverBlip, source, false ) end if laGetElementData ( source, "fraktion" ) == 9 then setElementVisibleTo ( ComptonDeliver, source, false ) setElementVisibleTo ( ComptonDeliverBlip, source, false ) end if laGetElementData ( source, "fraktion" ) == 10 then setElementVisibleTo ( WattsDeliver, source, false ) setElementVisibleTo ( WattsDeliverBlip, source, false ) end if laGetElementData ( driver, "fraktion" ) == 1 then setElementVisibleTo ( SFPDDeliver, driver, true ) setElementVisibleTo ( SFPDDeliverBlip, driver, true ) end end end addEventHandler ( "onPlayerVehicleExit", getRootElement(), vehicleExitMoneyTruck ) function vehicleDestroyedMoneyTruck () if laGetElementData ( source, "MoneyTruck" ) == 1 then setTimer(moneyclean, 3600000, 1) destroyElement ( veh, "MoneyTruck" ) destroyElement ( source ) setElementPosition ( veh, 999999, 999999, -50 ) local msg = "[GELDTRUCK]: Der Geldtruck ist explodiert!" sendMSGForFaction ( msg, 1, 0, 150, 0 ) sendMSGForFaction ( msg, 2, 200, 200, 0 ) sendMSGForFaction ( msg, 3, 200, 200, 0 ) sendMSGForFaction ( msg, 5, 200, 200, 0 ) sendMSGForFaction ( msg, 6, 0, 150, 0 ) sendMSGForFaction ( msg, 7, 200, 200, 0 ) sendMSGForFaction ( msg, 8, 0, 150, 0 ) sendMSGForFaction ( msg, 9, 200, 0, 0 ) sendMSGForFaction ( msg, 10, 200, 200, 0 ) outputLog ( "[GELDTRUCK]: Der Geldtruck ist explodiert!", "bad" ) end end addEventHandler ( "onVehicleExplode", getRootElement(), vehicleDestroyedMoneyTruck ) function moneyclean () moneytransport = 0 end SFPD_Deliver.lua : SFPDDeliver = createMarker ( 1592.6999511719, -1685.5, 4.8000099999999, "checkpoint", 7, 255, 0, 0, 150, getRootElement() ) SFPDDeliverBlip = createBlip ( 1592.6999511719, -1685.5, 4.8000001907349, 19, 2, 255, 0, 0, 255, 0, 99999.0, getRootElement() ) setElementVisibleTo ( SFPDDeliver, getRootElement(), false ) setElementVisibleTo ( SFPDDeliverBlip, getRootElement(), false ) function SFPDDeliver_func ( player, dim ) if isOnStateDuty (player) then local veh = getPedOccupiedVehicle ( player ) if veh then if getPedOccupiedVehicleSeat ( player ) == 0 then if getElementModel ( veh ) == 609 then if laGetElementData ( veh, "MoneyTruck" ) == 1 then local money = laGetElementData ( veh, "money" ) local kosten = laGetElementData ( veh, "kosten" ) SPFDGeld = tonumber ( MySQL_GetString("userdata", "Geld", "Name LIKE '"..player.."'") ) SFPDKASSE = tonumber ( MySQL_GetString("userdata", "Geld", "Name LIKE '"..player.."'") ) local SFPDGeldNEU = SFPDGeld + money local SFPDKASSENew = SFPDKASSE - kosten MySQL_SetString("userdata", "Geld", SFPDGeldNEU, "Name LIKE '"..player.."'") MySQL_SetString("userdata", "Geld", SFPDKASSENew, "Name LIKE '"..player.."'") SFPDGeld = tonumber ( MySQL_GetString("userdata", "Geld", "Name LIKE '"..player.."'") ) SFPDKASSE = tonumber ( MySQL_GetString("userdata", "Geld", "Name LIKE '"..player.."'") ) outputChatBox ( "Geldtruck abgegeben. Du erhältst "..money.."$ aus dem Geldtruck zurück!", player, 0, 200, 0 ) local msg = "[GELDTRUCK]: Der Geldtruck wurde erfolgreich abgegeben!" sendMSGForFaction ( msg, 1, 200, 0, 0 ) sendMSGForFaction ( msg, 2, 200, 200, 0 ) sendMSGForFaction ( msg, 3, 200, 200, 0 ) sendMSGForFaction ( msg, 6, 200, 0, 0 ) sendMSGForFaction ( msg, 7, 200, 200, 0 ) sendMSGForFaction ( msg, 8, 200, 0, 0 ) sendMSGForFaction ( msg, 9, 0, 150, 0 ) sendMSGForFaction ( msg, 10, 200, 200, 0 ) outputLog ( "[GELDTRUCK]: "..getPlayerName ( player ).." hat beim SFPD einen Moneytruck fuer "..money.."$ abgegeben!", "bad" ) laSetElementData ( player, "money", laGetElementData ( player, "money" ) + money ) givePlayerMoney ( player, money ) setElementVisibleTo ( SFPDDeliver, player, false ) setElementVisibleTo ( SFPDDeliverBlip, player, false ) triggerClientEvent ( player, "HudEinblendenMoney", getRootElement() ) removePedFromVehicle ( player ) removePedFromVehicle ( getVehicleOccupant ( veh, 1 ) ) setElementPosition ( veh, 0, 0, -500 ) destroyElement ( veh ) setTimer(moneyclean, 3600000, 1) end end end end end end addEventHandler ( "onMarkerHit", SFPDDeliver, SFPDDeliver_func ) I hope that anyone can help me with that problem. PS: Sorry for my bad english.. i'm from germany Link to comment
xTravax Posted August 6, 2014 Share Posted August 6, 2014 1) veh is not defined 2) im not sure 3) kokstruckcount is not defined as well Link to comment
MightyAnimals Posted August 6, 2014 Share Posted August 6, 2014 Nor is ..playername.. , or i might be blind. If its not. You need to define that. That error on empty line 23 should be gone. The local 'player' stuff. Link to comment
Addlibs Posted August 6, 2014 Share Posted August 6, 2014 Message only concerning your SFPD_Deliver.lua What's MySQL_GetString? Appears on lines 17, 18, 27 and 28. What's MySQL_SetString? Appears on lines 24 and 25. Never heard of these Anyway, [...] Name LIKE '"..player.."" (end of lines 17, 18, 24, 25, 27 and 28) is wrong. You're attempting to merge an MTA player element with a string. Link to comment
FlorjanMTARP Posted August 7, 2014 Share Posted August 7, 2014 Why would you make it so unique to add a MySQL GetString ? Link to comment
xScander Posted August 7, 2014 Author Share Posted August 7, 2014 I tried to change the ..player.. to ..playername.. and insert the following line: local playername = getPlayerName ( player ) but it doesn't work and I got a new error: [2014-08-07 22:15:40] ERROR: script/fraktionen/lapd/SFPD_deliver.lua:28: attempt to perform arithmetic on global 'SFPDGeld' (a nil value) Can someone tell me how I get this working? I'm not so new at scripting but this problem is something wich I can't solve 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