xeon17 Posted February 7, 2014 Share Posted February 7, 2014 I wanna crate a Check system for vehicle ( for custom vehicle : extample : Maverick ) How i can do it. Maverick = createVehicle ( 487, 251.64256286621,1920.413574218817,640630722046 ) radararea2 = createRadarArea( 110.91990, 1800.89435, 200, 145, 255, 255, 255, 225 ) function ( player ) local playerTeam = getPlayerTeam ( player ) if ( playerTeam ) then local r, g, b = getTeamColor ( playerTeam ) local aR, aG, aB = getRadarAreaColor(radararea2) if (r == aR) and (g == aG) and (b == aB) then outputChatBox ( "", player, 0, 0, 0, true ) else outputChatBox ( "[bASE] Your gang not bough this base.", player, 0, 0, 0, true ) cancelEvent() end end end addEventHandler( 'onVehicleStartEnter', root, function( player ) Link to comment
tosfera Posted February 7, 2014 Share Posted February 7, 2014 Why the hell are you doing this with matching colors? Rather just create a 'team' for the guys of the base and check the team. It is way easier! On your method, you can get conflicts with different bases. Link to comment
xeon17 Posted February 7, 2014 Author Share Posted February 7, 2014 Why the hell are you doing this with matching colors? Rather just create a 'team' for the guys of the base and check the team. It is way easier! On your method, you can get conflicts with different bases. Everyone can buy a base... so the radar area color change everytime and the owner of Base too. I think its a good way , so it check his team and the BASE (radar area of the vehicle Maverick ) if his Team have same color as Radar Area2 ( Base ) so he can use the vehcile , if not then he cant. Link to comment
Deepu Posted February 8, 2014 Share Posted February 8, 2014 EuFraT, first explain what is check system for vehicles? I will try to help you Link to comment
myonlake Posted February 8, 2014 Share Posted February 8, 2014 EuFraT, first explain what is check system for vehicles? I will try to help you I don't think you should help anyone as you can't fix your own mistakes and don't know what a variable is and how it's used. Link to comment
xeon17 Posted February 8, 2014 Author Share Posted February 8, 2014 The code i posted i wanna to use on custom vehicle's not on all , extample the vehicle Maverick i created i want the script only works on that vehicle. I need it for my bases whitch are based on Colors . Link to comment
xeon17 Posted February 8, 2014 Author Share Posted February 8, 2014 Anyone have a suggestion how to do it ? anything ? help ? Link to comment
myonlake Posted February 8, 2014 Share Posted February 8, 2014 I don't think the idea makes much sense, it could be a lot simpler by just making a element data check on whether the team or team name is the same as the player entering the vehicle, this way you won't get any issues between other radar areas and such, but uh, as you want it, here you go. Server-side createRadarArea( 110.91990, 1800.89435, 200, 145, 255, 255, 255, 225 ) -- Create a radar area local customVehicle = createVehicle( 487, 251.64256286621, 1920.413574218817, 64.0630722046, 0, 0, 0 ) -- Create a vehicle setElementData( customVehicle, "vehicles:custom", 1, false ) -- Set the element data on vehicles:custom addEventHandler( "onVehicleStartEnter", root, -- Initialize an event handler on when a player starts to enter a vehicle function( enteringPlayer ) if ( not getElementData( source, "vehicles:custom" ) ) or ( tonumber( getElementData( source, "vehicles:custom" ) ) ~= 1 ) then return end -- Check if the vehicle has vehicles:custom data local x, y, z = getElementPosition( enteringPlayer ) -- Get the position of the entering player local foundArea -- Initialize a variable with nil value representing a radar area for _,radarArea in ipairs( getElementsByType( "radararea" ) ) do -- Loop through all the radar areas if ( isInsideRadarArea( radarArea, x, y ) ) then -- If the player is inside it foundArea = radarArea -- Set the found area as this radar area that we were just checking break -- Break the loop and continue end end if ( foundArea ) then -- If we found a radar area local playerTeam = getPlayerTeam( enteringPlayer ) -- Get the player's team if ( playerTeam ) then -- If the player is in a team, then continue local r, g, b = getTeamColor( playerTeam ) -- Get the team's color local aR, aG, aB = getRadarAreaColor( foundArea ) -- Get the found radar area's color if ( r ~= aR ) or ( g ~= aG ) or ( b ~= aB ) then -- Check if the colors don't match each other outputChatBox( "[bASE] Your gang hasn't bought this base.", enteringPlayer, 0, 0, 0, false ) -- Output a warning message to the entering player cancelEvent( ) -- Cancel the event and don't let the player enter end end end end ) Link to comment
xeon17 Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) SOLVED. Edited February 8, 2014 by Guest Link to comment
myonlake Posted February 8, 2014 Share Posted February 8, 2014 Because there's no element called "customVehicle". You have to put "Maverick" there, and then make the same function for each vehicle individually. The best way to do this is that you create an array of vehicle information, and then loop through and spawn each vehicle with the loop so that the code looks cleaner. Link to comment
xeon17 Posted February 8, 2014 Author Share Posted February 8, 2014 Because there's no element called "customVehicle". You have to put "Maverick" there, and then make the same function for each vehicle individually. The best way to do this is that you create an array of vehicle information, and then loop through and spawn each vehicle with the loop so that the code looks cleaner. I understand i'm going to do it , thank for all your help was very usefull for my bases script Ty BRO ! 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