aguia Posted November 8, 2015 Share Posted November 8, 2015 (edited) Hello, my friend made this script for me but I got a problem with it. I want to remove the licence from the vehicles, from all of them. I tried removing the function doesPlayerHaveLiceForVehicle but didn't works... I were learning those lines, but didn't understood at all. So, I'd appreciate a help -- The Vehicle Spawn Gui -- vehiclesWindow = guiCreateWindow(395,237,241,413,"Vehicles",false) vehiclesGrid = guiCreateGridList(9,26,221,307,false,vehiclesWindow) guiGridListSetSelectionMode(vehiclesGrid,0) spawnVehicleSystemButton = guiCreateButton(9,337,220,30,"Spawn Vehicle",false,vehiclesWindow) closeWindowButton = guiCreateButton(9,373,220,30,"Close Window",false,vehiclesWindow) guiGridListSetSortingEnabled ( vehiclesGrid, false ) vehicleName = guiGridListAddColumn( vehiclesGrid, " Vehiclename:", 0.80 ) addEventHandler("onClientGUIClick", closeWindowButton, function() guiSetVisible(vehiclesWindow, false) showCursor(false,false) guiGridListClear ( vehiclesGrid ) end, false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(vehiclesWindow,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(vehiclesWindow,x,y,false) guiWindowSetMovable (vehiclesWindow, true) guiWindowSetSizable (vehiclesWindow, false) guiSetVisible (vehiclesWindow, false) -- MTA VEHICLES IDS/NAMES -- local swatJobVehicles = { [596] = {"Police Car (LS)", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [597] = {"Police Car (SF)", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [598] = {"Police Car (LV)", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [599] = {"Police Ranger", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [415] = {"Cheetah", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [426] = {"Premier", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [428] = {"Securicar", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [451] = {"Turismo",131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [560] = {"Sultan",131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [579] = {"Huntley", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [601] = {"S.W.A.T", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [427] = {"Enforcer",131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, [523] = {"HPV1000", 106, 1, 1, 1}, [490] = {"FBI Rancher", 131,131,131,131,r=0,g=20,b=90,r2=255,g2=255,b2=255}, } local swatHeli = { [497] = {"Police Maverick", 53, 1, 1, 1}, [563] = {"Raindance",53,1,1,1}, [447] = {"Seasparrow",53, 1 , 1, 1}, [476] = {"Rustler", 53, 1 , 1, 1}, } -- VEHICLE SPAWNERS LOCATIONS /TEAM -- local vehicleMarkers = { --SWAT {1813.8505859375, -1370.5888671875, 24.537517547607, 39, 64, 225, swatHeli, "SWAT", "SWAT Team", 0, "noOccupation" }, {1793.8505859375, -1370.5888671875, 24.537517547607, 39, 64, 225, swatHeli, "SWAT", "SWAT Team", 0, "noOccupation" }, {1812.72265625, -1367.7529296875, 13.645312309265, 39, 64, 225, swatJobVehicles, "SWAT", "SWAT Team", 180, "noOccupation" }, {1803.361328125, -1367.7529296875, 13.645312309265, 39, 64, 225, swatJobVehicles, "SWAT", "SWAT Team", 180, "noOccupation" }, {1793.361328125, -1367.7529296875, 13.645312309265, 39, 64, 225, swatJobVehicles, "SWAT", "SWAT Team", 180, "noOccupation" }, } -- SCRIPT -- local JobsToTables = { } local amarkers = {} local workingWithTable=false for i,v in pairs(vehicleMarkers) do if getPlayerTeam ( localPlayer ) then local overRide=false if v[8] ~= nil and v[8] == "Police" then if getTeamName(getPlayerTeam ( localPlayer )) == "Police" or getTeamName(getPlayerTeam ( localPlayer )) == "SWAT" then overRide=true end end if overRide==false and getTeamName(getPlayerTeam ( localPlayer )) == v[8] and getElementData(localPlayer, "Occupation") == v[9] or getTeamName(getPlayerTeam ( localPlayer )) == v[8] and v[11] == "noOccupation" or getTeamName(getPlayerTeam ( localPlayer )) == v[11] or getTeamName(getPlayerTeam ( localPlayer )) == v[12] or v[8] == nil and v[9] == nil then elref = createMarker(v[1], v[2], v[3] -1, "cylinder", 2.2, v[4], v[5], v[6]) amarkers [elref ] = v[7] setElementData(elref, "freeVehiclesSpawnRotation", v[10]) setElementData(elref, "isMakerForFreeVehicles", true) if ( v[11] == "aGroup" ) then setElementData(elref, "groupMarkerName", v[15] ) end end end end local workingWith = {} addEventHandler("onClientMarkerHit", root, function(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" and getElementData(source, "isMakerForFreeVehicles") == true and hitElement == localPlayer then guiGridListClear ( vehiclesGrid ) if not isPedInVehicle(localPlayer) then if (amarkers [source] ) then workingWithTable=amarkers [source] for i,v in pairs( amarkers [source] ) do if hitElement == localPlayer then local px,py,pz = getElementPosition ( hitElement ) local mx, my, mz = getElementPosition ( source ) if ( pz-3 < mz ) and ( pz+3 > mz ) then if ( getElementData( source, "groupMarkerName" ) ) and ( getElementData( localPlayer, "Group" ) ) and not ( getElementData( source, "groupMarkerName" ) == getElementData( localPlayer, "Group" ) ) then exports.dxmsg:createNewDxMessage("You are not allowed to use this vehicle marker!", 225 ,0 ,0) else if not(getElementData(localPlayer,"Group")) then exports.dxmsg:createNewDxMessage("You are not allowed to use this vehicle marker!", 225 ,0 ,0) return end local row = guiGridListAddRow ( vehiclesGrid ) workingWith[tostring(v[1])] = tonumber(i) guiGridListSetItemText ( vehiclesGrid, row, vehicleName, tostring(v[1]), false, false ) guiGridListSetItemData ( vehiclesGrid, row, vehicleName, tostring(i) ) guiSetVisible (vehiclesWindow, true) showCursor(true,true) theVehicleRoation = getElementData(source, "freeVehiclesSpawnRotation") theMarker = source end end end end end end end end) -- Reload the markers -- function reloadFreeVehicleMarkers () for i,v in pairs( amarkers ) do destroyElement(i) end amarkers = {} for i,v in pairs(vehicleMarkers) do if getTeamName(getPlayerTeam ( localPlayer )) == v[8] and getElementData(localPlayer, "Occupation") == v[9] or getTeamName(getPlayerTeam ( localPlayer )) == v[8] and v[11] == "noOccupation" or getTeamName(getPlayerTeam ( localPlayer )) == v[11] or getTeamName(getPlayerTeam ( localPlayer )) == v[12] or v[8] == nil and v[9] == nil then elref = createMarker(v[1], v[2], v[3] -1, "cylinder", 2.2, v[4], v[5], v[6]) amarkers [elref ] = v[7] setElementData(elref, "freeVehiclesSpawnRotation", v[10]) setElementData(elref, "isMakerForFreeVehicles", true) if ( v[11] == "aGroup" ) then setElementData(elref, "groupMarkerName", v[15] ) end end end end addEvent("reloadFreeVehicleMarkers", true) addEventHandler("reloadFreeVehicleMarkers", root, reloadFreeVehicleMarkers ) function spawnTheVehicle () local x,y,z = getElementPosition(theMarker) local selectedVehicle = guiGridListGetItemText ( vehiclesGrid, guiGridListGetSelectedItem ( vehiclesGrid ), 1 ) if selectedVehicle == "" or selectedVehicle == " " then exports.dxmsg:createNewDxMessage("You didnt select a vehicle!", 225 ,0 ,0) else local selectedRow, selectedColumn = guiGridListGetSelectedItem(vehiclesGrid) local theVehicleID = workingWith[tostring(selectedVehicle)] -- local theVehicleID = tonumber(guiGridListGetItemData ( vehiclesGrid, selectedRow, selectedColumn )) if ( tonumber( theVehicleID) == 481 ) or ( tonumber( theVehicleID) == 510 ) or ( tonumber( theVehicleID) == 509 ) or ( tonumber( theVehicleID) == 462 ) or ( getElementData( localPlayer, "Occupation" ) == "Criminal" ) then if ( getElementData( localPlayer, "wantedPoints" ) >= 20 ) then exports.dxmsg:createNewDxMessage("You can't spawn free vehicles when having more then 1 wanted stars!", 225 ,0 ,0) else local getTable = workingWithTable --JobsToTables[getElementData(localPlayer, "Occupation")] or JobsToTables[getTeamName(getPlayerTeam ( localPlayer ))] local vehicle,color1,color2,color3,color4 = getTable[theVehicleID][1],getTable[theVehicleID][2],getTable[theVehicleID][3],getTable[theVehicleID][4],getTable[theVehicleID][5]--unpack( getTable[tonumber( theVehicleID )] ) local r,g,b=nil,nil,nil local r2,g2,b2=nil,nil,nil if getTable[theVehicleID].r ~= nil then r,g,b=getTable[theVehicleID].r,getTable[theVehicleID].g,getTable[theVehicleID].b end if getTable[theVehicleID].r2 ~= nil then r2,g2,b2=getTable[theVehicleID].r2,getTable[theVehicleID].g2,getTable[theVehicleID].b2 end triggerServerEvent("spawnVehicleSystem", localPlayer, x, y, z, theVehicleID, color1, color2, color3, color4, theVehicleRoation,r,g,b,r2,g2,b2) guiSetVisible (vehiclesWindow, false) showCursor(false,false) guiGridListClear ( vehiclesGrid ) end elseif doesPlayerHaveLiceForVehicle(tonumber(theVehicleID)) then local getTable = workingWithTable --JobsToTables[getElementData(localPlayer, "Occupation")] or JobsToTables[getTeamName(getPlayerTeam ( localPlayer ))] local vehicle,color1,color2,color3,color4 = getTable[theVehicleID][1],getTable[theVehicleID][2],getTable[theVehicleID][3],getTable[theVehicleID][4],getTable[theVehicleID][5]--unpack( getTable[tonumber( theVehicleID )] ) local r,g,b=nil,nil,nil local r2,g2,b2=nil,nil,nil if getTable[theVehicleID].r ~= nil then r,g,b=getTable[theVehicleID].r,getTable[theVehicleID].g,getTable[theVehicleID].b end if getTable[theVehicleID].r2 ~= nil then r2,g2,b2=getTable[theVehicleID].r2,getTable[theVehicleID].g2,getTable[theVehicleID].b2 end triggerServerEvent("spawnVehicleSystem", localPlayer, x, y, z, theVehicleID, color1, color2, color3, color4, theVehicleRoation,r,g,b,r2,g2,b2) guiSetVisible (vehiclesWindow, false) showCursor(false,false) guiGridListClear ( vehiclesGrid ) else exports.dxmsg:createNewDxMessage("You don't have a licence for this type of vehicle!", 225 ,0 ,0) end end end addEventHandler("onClientGUIClick", spawnVehicleSystemButton, spawnTheVehicle, false) function doesPlayerHaveLiceForVehicle (vehicleID) local playtime = getElementData(localPlayer,"playTime") if getVehicleType ( vehicleID ) == "Automobile" or getVehicleType ( vehicleID ) == "Monster Truck" or getVehicleType ( vehicleID ) == "Quad" or getVehicleType ( vehicleID ) == "Trailer" then if playtime == false or playtime==nil then return true end if math.floor((tonumber(playtime)/60)) < 10 then return true end if getElementData(localPlayer, "carLicence") then return true else return false end elseif getVehicleType ( vehicleID ) == "Plane" then if getElementData(localPlayer, "planeLicence") then return true else return false end elseif getVehicleType ( vehicleID ) == "Helicopter" then if getElementData(localPlayer, "chopperLicence") then return true else return false end elseif getVehicleType ( vehicleID ) == "Bike" or getVehicleType ( vehicleID ) == "BMX" then if getElementData(localPlayer, "bikeLicence") then return true else return false end elseif getVehicleType ( vehicleID ) == "Boat" then if getElementData(localPlayer, "boatLicence") then return true else return false end end end Ex.: As a SWAT member I can spawn all those car from the "swatJobVehicles", less the "HPV1000". Why ? "You don't have a licence for this type of vehicle!" appears. The same thing applies for those all "swatHeli" vehicles. Edited November 10, 2015 by Guest Link to comment
raynner Posted November 8, 2015 Share Posted November 8, 2015 Hello friend try to observe parts of team because like most of us scriptes we panels related to corporations for team and your script and very large yield revisalo lazy totally more found functions with (getTeamName) this server to check the name of the team and this (getPlayerTeam) to see if the player who is doing the action is in the team so I recommend you watch these parts of your script as (getTeamName, getPlayerTeam, setPlayerTeam) Well I have helped as I noticed, for what appears to have SWAT Teams and Police Link to comment
aguia Posted November 10, 2015 Author Share Posted November 10, 2015 I didn't understand anything from you raynner, I think you were using the google translate... Link to comment
GTX Posted November 10, 2015 Share Posted November 10, 2015 Check doesPlayerHaveLiceForVehicle function. setElementData(localPlayer, "carLicence", false) setElementData(localPlayer, "planeLicence", false) setElementData(localPlayer, "chopperLicence", false) setElementData(localPlayer, "bikeLicence", false) setElementData(localPlayer, "boatLicence", false) This should remove local player's licenses. Link to comment
raynner Posted November 19, 2015 Share Posted November 19, 2015 An example and this simple script that I made him do the following it creates a team like that and started on the server and you specify the id of the vehicles you want only this team can drive it (I left the free ride for everyone) to get in the car if the player no team specified and it can not address just use the passenger vehicle I think this will help you understand and What do I speak up! teamFletiwis = createTeam ( "LOS RED", 255, 0, 0 ) Vehicles = { [445]=true,[506]=true } Teams = { [teamFletiwis] =true } function enterVehicle ( thePlayer, seat, jacked ) if getElementType ( thePlayer ) == "player" then if ( Vehicles[getElementModel ( source )] ) and ( not Teams[getPlayerTeam( thePlayer )] ) and ( seat == 0 ) then removePedFromVehicle( thePlayer ) outputChatBox("#00FF00Apenas Os Membros Da Equipe #FF0000LOS RED #00FF00Podem Dirigir este Veiculo!", thePlayer, 255, 255, 255, true) end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 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