function auto_buy_func ( player, id, vname )
local pname = getPlayerName ( player )
local liefzeit = dbQuery ( handler, "SELECT Lieferzeit FROM carhouses_vehicles WHERE Id LIKE '"..id.."'")
local VehID = dbQuery ( handler, "SELECT Typ FROM carhouses_vehicles WHERE Id LIKE '"..id.."'")
if liefzeit then
if tonumber ( liefzeit ) == 0 then
if hasPlayerLicense ( player, tonumber(VehID) ) then
if vioGetElementData ( player, "maxcars" ) > vioGetElementData ( player, "curcars" ) then
local i = true
vioSetElementData ( player, "carbuyslot", 0 )
carslotnr = 1
succesful = false
for i = 1, tonumber(vioGetElementData ( player, "maxcars" )) do
carslotzahl = "carslot"..carslotnr
if tonumber(vioGetElementData ( player, carslotzahl )) == 0 then
vioSetElementData ( player, "carbuyslot", carslotnr )
succesful = true
break
else
y = carslotnr
carslotnr = ( y + 1 )
end
end
if vioGetElementData( player, "maxcars" ) == vioGetElementData ( player, "curcars") then
triggerClientEvent ( player, "infobox_start", getRootElement(), "Du hast bereits zuviele\nFahrzeuge, zerstoere oder\nverkaufe eines deiner\nalten!", 5000, 255, 0, 0 )
else
-- Definition
local house = MySQL_GetString ( "carhouses_vehicles", "House", "Id LIKE '"..id.."'" )
local Spawn_X = MySQL_GetString ( "carhouses_vehicles", "Spawn_X", "Id LIKE '"..id.."'" )
local Spawn_Y = MySQL_GetString ( "carhouses_vehicles", "Spawn_Y", "Id LIKE '"..id.."'" )
local Spawn_Z = MySQL_GetString ( "carhouses_vehicles", "Spawn_Z", "Id LIKE '"..id.."'" )
local Spawn_RX = MySQL_GetString ( "carhouses_vehicles", "Spawn_RX", "Id LIKE '"..id.."'" )
local Spawn_RY = MySQL_GetString ( "carhouses_vehicles", "Spawn_RY", "Id LIKE '"..id.."'" )
local Spawn_RZ = MySQL_GetString ( "carhouses_vehicles", "Spawn_RZ", "Id LIKE '"..id.."'" )
-- Ende
vioSetElementData ( player, "ordercars", vioGetElementData ( player, "ordercars" ) - 1 )
setElementDimension ( player, 0 )
datasave_remote ( player )
setElementInterior ( player, 0 )
fadeCamera( player, true)
setCameraTarget( player, player )
local pslot = vioGetElementData ( player, "carbuyslot" )
_G[getPrivVehString ( pname, pslot )] = createVehicle ( VehID, Spawn_X, Spawn_Y, Spawn_Z, Spawn_RX, Spawn_RY, Spawn_RZ, pname )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "owner", pname )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "name", "privVeh"..pname..pslot )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "carslotnr_owner", pslot )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "locked", true )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "fuelstate", 100 )
setVehicleLocked ( _G[getPrivVehString ( pname, pslot )], true )
local z = vioGetElementData ( player, "carbuyslot" )
vioSetElementData ( player, "carslot"..z, 1 )
vioSetElementData ( player, "curcars", vioGetElementData ( player, "curcars" )+1 )
datasave_remote ( player )
local Besitzer = vioGetElementData ( _G[getPrivVehString ( pname, pslot )], "owner" )
local Beschlagnahmung = 0
vioSetElementData(_G[getPrivVehString ( pname, pslot )], "Beschlagnahmt", 0)
local Beschlagzeit = 0
setElementData(_G[getPrivVehString ( pname, pslot )], "Beschlagzeit", 0)
if not Tuning then
Tuning = "|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|"
end
local Spawnpos_X, Spawnpos_Y, Spawnpos_Z = getElementPosition ( _G[getPrivVehString ( pname, pslot )] )
local Slot = vioGetElementData ( _G[getPrivVehString ( pname, pslot )], "carslotnr_owner" )
setVehicleRotation ( _G[getPrivVehString ( pname, pslot )], Spawn_RX, Spawn_RY, Spawn_RZ )
local Spawnrot_X, Spawnrot_Y, Spawnrot_Z = getVehicleRotation ( _G[getPrivVehString ( pname, pslot )] )
local Farbe1, Farbe2, Farbe3, Farbe4
local Paintjob
if not c1 or not c2 or not c3 or not c4 then
Farbe1, Farbe2, Farbe3, Farbe4 = getVehicleColor ( _G[getPrivVehString ( pname, pslot )] )
else
Farbe1, Farbe2, Farbe3, Farbe4 = c1, c2, c3, c4
setVehicleColor ( _G[getPrivVehString ( pname, pslot )], c1, c2, c3, c4 )
end
if not p then
Paintjob = getVehiclePaintjob ( _G[getPrivVehString ( pname, pslot )] )
else
Paintjob = p
setVehiclePaintjob ( _G[getPrivVehString ( pname, pslot )], p )
end
local Benzin = vioGetElementData ( _G[getPrivVehString ( pname, pslot )], "fuelstate" )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "stuning", "0|0|0|0|0|0|" )
local color = "|"..Farbe1.."|"..Farbe2.."|"..Farbe3.."|"..Farbe4.."|"
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "color", color )
vioSetElementData ( _G[getPrivVehString ( pname, pslot )], "lcolor", "|255|255|255|" )
setPrivVehCorrectLightColor ( _G[getPrivVehString ( pname, pslot )] )
specPimpVeh ( _G[getPrivVehString ( pname, pslot )] )
SaveCarData ( player )
outputChatBox ( "Glueckwunsch, du hast das Fahrzeug gekauft! Tippe /vehhelp für mehr Infomationen oder rufe das Hilfemenue auf!", player, 0, 255, 0 )
checkCarWahnAchiev( player )
warpPedIntoVehicle ( player, _G[getPrivVehString (pname, pslot )], 0 )
toggleControl ( player, "fire", true )
toggleControl ( player, "enter_exit", true )
toggleControl ( player, "action", true )
setElementData ( player,"nodmzone", 0)
local rnddim = math.random (1, 100)
setElementDimension ( player, rnddim)
setElementDimension ( _G[getPrivVehString (pname, pslot )], rnddim)
setTimer (ghostbuy, 10000, 1, player, _G[getPrivVehString (pname, pslot )])
outputChatBox ( "WICHTIG: Fahre an einen ANDEREN Ort und tippe /park ein, um dein Fahrzeug dort abzustellen!", player, 125, 0, 0 )
outputChatBox ( "Du kannst es dort mit /towveh [Nummer] respawnen - sonst wird es geloescht!!!", player, 125, 0, 0 )
local result = dbQuery(handler, "INSERT INTO vehicles (Besitzer, Typ, Tuning, Spawnpos_X, Spawnpos_Y, Spawnpos_Z, Spawnrot_X, Spawnrot_Y, Spawnrot_Z, Farbe, Paintjob, Benzin, Slot) VALUES ('"..Besitzer.."', '"..VehID.."', '"..Tuning.."', '"..Spawnpos_X.."', '"..Spawnpos_Y.."', '"..Spawnpos_Z.."', '"..Spawnrot_X.."', '"..Spawnrot_Y.."', '"..Spawnrot_Z.."', '"..color.."', '"..Paintjob.."', '"..Benzin.."', '"..Slot.."')")
if ( not result ) then
outputDebugString("Error executing the query: (" .. mysql_errno(handler) .. ") " .. mysql_error(handler))
destroyElement ( _G[getPrivVehString ( pname, pslot )] )
else
dbFree(result)
end
MySQL_DelRow ( "carhouses_vehicles", "Id LIKE '"..id.."'" )
return true
end
end
else
outputChatBox ( "Du hast nicht die erforderlichen Scheine / Boni!", player, 255, 0, 0 )
end
elseif tonumber ( liefzeit ) > 0 then
outputChatBox ( "Fahrzeug wurde noch nicht geliefert.\nBitte habe noch ein wenig Geduld.", player, 255, 0, 0 )
end
else
outputChatBox ( "Es wurde kein Fahrzeug ausgewählt.", player, 255, 0, 0 )
end
end
Alles anzeigen
sry dass ich soviel frage, bin noch beim lernen und diese db befehle verwirren mich noch etwas^^