Sign in to follow this  
Specter

Problem/Problema Script

Recommended Posts

Problem/Problema Script

s6qeeg.jpg

30bib2w.jpg

vShopCol = {}

spawnAnnul = {}

markerVehic = {}

afText = {}

myTextItem = {}

function guiStart ()

local node = xmlLoadFile("data\\Carshops.xml")

local vNum2 = 0

while ( xmlFindChild ( node, "carshop", vNum2 ) ~= false ) do

local vNum3 = 0

local shop = xmlFindChild ( node, "carshop", vNum2 )

while ( xmlFindChild ( shop, "carshopcol", vNum3 ) ~= false ) do

local shopCol = xmlFindChild ( shop, "carshopcol", vNum3 )

local shopName = xmlNodeGetAttribute ( shopCol, "name" )

local pX = xmlNodeGetAttribute ( shopCol, "posX" )

local pY = xmlNodeGetAttribute ( shopCol, "posY" )

local pZ = xmlNodeGetAttribute ( shopCol, "posZ" )

local m1 = xmlNodeGetAttribute ( shopCol, "M1" )

local spawnPX = xmlNodeGetAttribute ( shopCol, "spawnPX" )

local spawnPY = xmlNodeGetAttribute ( shopCol, "spawnPY" )

local spawnPZ = xmlNodeGetAttribute ( shopCol, "spawnPZ" )

local spawnRZ = xmlNodeGetAttribute ( shopCol, "spawnRZ" )

IspawnCol = createColSphere ( spawnPX, spawnPY, spawnPZ, 2.4 )

vShopCol1 = createColSphere ( pX, pY, pZ, 1 )

setElementData ( IspawnCol, "SpawnPointName", ""..shopName.."" )

setElementData ( IspawnCol, "sRz", ""..spawnRZ.."" )

setElementData ( vShopCol1, "tList", ""..m1.."" )

setElementData ( vShopCol1, "SpawnShopName", ""..shopName.."" )

createMarker ( pX, pY, pZ, "cylinder", 1, 0, 0, 255, 200 )

addEventHandler( "onColShapeHit", IspawnCol, spawnColCol )

addEventHandler( "onColShapeHit", vShopCol1, conCol )

addEventHandler( "onColShapeLeave", IspawnCol, setDataCol1 )

local vNum4 = 0

while ( xmlFindChild ( shopCol, "model", vNum4 ) ~= false ) do

local modelE = xmlFindChild ( shopCol, "model", vNum4 )

local pX1 = xmlNodeGetAttribute ( modelE, "posX" )

local pY1 = xmlNodeGetAttribute ( modelE, "posY" )

local pZ1 = xmlNodeGetAttribute ( modelE, "posZ" )

local rZ = xmlNodeGetAttribute ( modelE, "rot" )

local id = xmlNodeGetAttribute ( modelE, "name" )

local vehicle = createVehicle ( id, pX1, pY1, pZ1, 0, 0, rZ )

setTimer ( setElementFrozen , 1000, 1, vehicle, true )

setVehicleLocked ( vehicle, true )

setVehicleDamageProof ( vehicle, true )

vNum4 = vNum4 + 1

end

vNum3 = vNum3 + 1

end

vNum2 = vNum2 + 1

end

end

addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), guiStart )

function spawnColCol (element)

if getElementType ( element ) == "vehicle" then

-- outputChatBox ( " eaaaaaaaa " )

setElementData ( source, "etatPlace", "OQP" )

end

end

function setDataCol1 (element)

if getElementType ( element ) == "vehicle" then

local player = getVehicleOccupant ( element, 0 )

setElementData ( source, "etatPlace", "libre" )

if ( spawnAnnul[player] ) ~= nil then

killTimer ( spawnAnnul[player] )

spawnAnnul[player] = nil

end

end

end

function conCol (element)

if getElementType ( element ) == "player" then

-- local player = getVehicleOccupant ( element, 0 )

atList, atList1 = getElementData ( source, "tList" )

local shopName = getElementData ( source, "SpawnShopName" )

setElementData ( element, "shopName", ""..shopName.."" )

triggerClientEvent (element, "guiStart" , getRootElement(), atList, atList1 )

--else

-- local player = element

end

end

function vehicleCreat( player, cost, vId, x, y, z, nPlayer, sRz, cColor1, cColor2, cColor3, cColor4 )

-- outputChatBox ( ""..cColor1.."" )

removeElementData ( player, "shopName" )

if getPlayerMoney ( player ) >= math.abs(cost) then

vehicle = createVehicle ( vId, x, y, z, 0, 0, sRz )

markerVehic[player] = createMarker ( x, y, z+3, "arrow", 1.5, 255, 255, 0, 170, player )

setVehicleColor ( vehicle, cColor1, cColor2, cColor3, cColor4 )

setElementData ( vehicle, "consVehicleOwner", ""..nPlayer.."" )

setVehicleDamageProof ( vehicle, true )

setVehicleLocked ( vehicle, true )

takePlayerMoney ( player, math.abs(cost) )

if ( vehicle ) then

toggleVehicleRespawn ( vehicle, false )

end

spawnAnnul[player] = setTimer ( delayedSpawn, 5000, 1, "15", vehicle, player, cost )

warnText ( "15 seconds to take your vehicle", player)

else

warnText ( "You cannot afford to fit this Vehicle!", player )

end

end

addEvent( "but_applyVehicle", true )

addEventHandler( "but_applyVehicle", getRootElement(), vehicleCreat )

function delayedSpawn ( curTime, vehicle, player, cost )

if curTime ~= 0 then

curTime = curTime -1

spawnAnnul[player] = setTimer ( delayedSpawn, 1000, 1, curTime, vehicle, player, cost )

warnText ( ""..curTime.."", player )

else

warnText ( "Vehicule repaid !", player )

givePlayerMoney ( player, math.abs(cost) )

triggerClientEvent ( getRootElement(), "destroyvehicles", getRootElement(), vehicle )

if ( markerVehic[player] ) then

destroyElement ( markerVehic[player] )

end

setTimer ( destroyElement , 100, 1, vehicle )

end

end

function vExplode ()

if getElementData ( source , "consVehicleOwner" ) ~= false then

toggleVehicleRespawn ( source, false )

setTimer(destroyElement, 5000, 1, source)

end

end

addEventHandler ( "onVehicleExplode", getResourceRootElement(getThisResource()), vExplode )

function consVehicleEnter (player, seat, jacked)

vProp = getElementData ( source, "consVehicleOwner" )

if vProp == getPlayerNametagText(player) then

setVehicleLocked ( source, false )

setVehicleDamageProof ( source, false )

if ( markerVehic[player] ) then

destroyElement ( markerVehic[player] )

markerVehic[player] = nil

end

-- else

-- local vType = getVehicleType ( source )

-- if vType == "boat" or vType == "bike" then ------------------------------------<<<<<<<<< POUR LA VERSION 1.0

-- cancelEvent()

-- end

end

end

addEventHandler ( "onVehicleStartEnter" , getResourceRootElement(getThisResource()), consVehicleEnter )

function warnText ( aWText, player )

if ( myTextItem[player] ) then

textDestroyTextItem ( myTextItem[player])

end

afText[player] = textCreateDisplay ()

textDisplayAddObserver( afText[player], player )

myTextItem[player] = textCreateTextItem ( aWText, 0.22, 0.8, 2 , 255, 0, 0, 255, 3 )

textDisplayAddText ( afText[player], myTextItem[player] )

-- outputChatBox ( textA, player )

setTimer ( textDestroyTextItem, 5000, 1, myTextItem[player], player )

end

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.