Tete omar Posted July 20, 2012 Share Posted July 20, 2012 Hi, i got a problem here server side function nice(player) histeam = createTeam ("another", 255, 0, 0 ) triggerClientEvent(player,"knowledge",player,histeam) end addEventHandler("onResourceStart", getRootElement(), nice) client side addEvent("knowledge", true) function knowledge(histeam) if getPlayerTeam(localPlayer) == "histeam" then for _,vehi in ipairs (getElementsByType("vehicle")) do local getType = getElementModel (vehi); if getType == 429 then -- the vehicle model setVehicleLocked ( getType, false ); if getPlayerTeam(localPlayer) == nil then -- if another player then lock the vehicle setVehicleLocked ( getType, true ); outputChatBox("sorry, but you're not in this team"); end end end end end addEventHandler('knowledge', root, knowledge) i want here if not this player in this team then lock this vehicle model. Link to comment
DNL291 Posted July 20, 2012 Share Posted July 20, 2012 Try this. histeam = createTeam ("another", 255, 0, 0 ) function nice(player) triggerClientEvent(player,"knowledge",player,histeam) end addEventHandler("onVehicleStartEnter", root, nice) addEvent("knowledge", true) function knowledge(histeam) for _,vehi in ipairs (getElementsByType("vehicle")) do local getType = getElementModel (vehi); if getTeamName(getPlayerTeam(localPlayer)) == histeam then if getType == 429 then -- the vehicle model setVehicleLocked ( getType, false ); end else setVehicleLocked ( getType, true ); outputChatBox("sorry, but you're not in this team"); end end end addEventHandler('knowledge', root, knowledge) Link to comment
TwiX! Posted July 20, 2012 Share Posted July 20, 2012 in your code all players can use 429 vehicle you need 1)create team 2)set player to team 3)set team in to the account 4)then get account data(player),trigger event with his team 5)if his team == police(as example) unlock vehicle,esle lock Link to comment
Anderl Posted July 20, 2012 Share Posted July 20, 2012 Try this. histeam = createTeam ("another", 255, 0, 0 ) function nice(player) triggerClientEvent(player,"knowledge",player,histeam) end addEventHandler("onVehicleStartEnter", root, nice) addEvent("knowledge", true) function knowledge(histeam) for _,vehi in ipairs (getElementsByType("vehicle")) do local getType = getElementModel (vehi); if getTeamName(getPlayerTeam(localPlayer)) == histeam then if getType == 429 then -- the vehicle model setVehicleLocked ( getType, false ); end else setVehicleLocked ( getType, true ); outputChatBox("sorry, but you're not in this team"); end end end addEventHandler('knowledge', root, knowledge) The code is wrong anyway. Client-side: addEvent( 'Event::Knowledge', true ); addEventHandler( 'onClientResourceStart', resourceRoot, function( ) createTeam( 'Another', 255, 0, 0 ); for _, v in ipairs( getElementsByType 'player' ) do triggerEvent( v, 'Event::Knowledge', v, getTeamFromName( 'Another' ) ); end end ) addEventHandler( 'Event::Knowledge', root, function( pTeam ) for _, v in ipairs( getElementsByType( 'vehicle' ) ) do if( getTeamName( getPlayerTeam( source ) ) == getTeamName( pTeam ) ) then if( getElementModel( v ) == 429 ) then setVehicleLocked( v, false ); end else setVehicleLocked( v, true ); end end end ) Link to comment
Tete omar Posted July 20, 2012 Author Share Posted July 20, 2012 Try this. histeam = createTeam ("another", 255, 0, 0 ) function nice(player) triggerClientEvent(player,"knowledge",player,histeam) end addEventHandler("onVehicleStartEnter", root, nice) addEvent("knowledge", true) function knowledge(histeam) for _,vehi in ipairs (getElementsByType("vehicle")) do local getType = getElementModel (vehi); if getTeamName(getPlayerTeam(localPlayer)) == histeam then if getType == 429 then -- the vehicle model setVehicleLocked ( getType, false ); end else setVehicleLocked ( getType, true ); outputChatBox("sorry, but you're not in this team"); end end end addEventHandler('knowledge', root, knowledge) The code is wrong anyway. Client-side: addEvent( 'Event::Knowledge', true ); addEventHandler( 'onClientResourceStart', resourceRoot, function( ) createTeam( 'Another', 255, 0, 0 ); for _, v in ipairs( getElementsByType 'player' ) do triggerEvent( v, 'Event::Knowledge', v, getTeamFromName( 'Another' ) ); end end ) addEventHandler( 'Event::Knowledge', root, function( pTeam ) for _, v in ipairs( getElementsByType( 'vehicle' ) ) do if( getTeamName( getPlayerTeam( source ) ) == getTeamName( pTeam ) ) then if( getElementModel( v ) == 429 ) then setVehicleLocked( v, false ); end else setVehicleLocked( v, true ); end end end ) Well, that's very wrong even more. Client-side: createTeam( 'Another', 255, 0, 0 ); ???? Link to comment
Anderl Posted July 20, 2012 Share Posted July 20, 2012 Try this. histeam = createTeam ("another", 255, 0, 0 ) function nice(player) triggerClientEvent(player,"knowledge",player,histeam) end addEventHandler("onVehicleStartEnter", root, nice) addEvent("knowledge", true) function knowledge(histeam) for _,vehi in ipairs (getElementsByType("vehicle")) do local getType = getElementModel (vehi); if getTeamName(getPlayerTeam(localPlayer)) == histeam then if getType == 429 then -- the vehicle model setVehicleLocked ( getType, false ); end else setVehicleLocked ( getType, true ); outputChatBox("sorry, but you're not in this team"); end end end addEventHandler('knowledge', root, knowledge) The code is wrong anyway. Client-side: addEvent( 'Event::Knowledge', true ); addEventHandler( 'onClientResourceStart', resourceRoot, function( ) createTeam( 'Another', 255, 0, 0 ); for _, v in ipairs( getElementsByType 'player' ) do triggerEvent( v, 'Event::Knowledge', v, getTeamFromName( 'Another' ) ); end end ) addEventHandler( 'Event::Knowledge', root, function( pTeam ) for _, v in ipairs( getElementsByType( 'vehicle' ) ) do if( getTeamName( getPlayerTeam( source ) ) == getTeamName( pTeam ) ) then if( getElementModel( v ) == 429 ) then setVehicleLocked( v, false ); end else setVehicleLocked( v, true ); end end end ) Well, that's very wrong even more. Client-side: createTeam( 'Another', 255, 0, 0 ); ???? Damn shit. Forgot that 'createTeam' was only server-sided. Just change 'onClientResourceStart' event to server-side and change its name to 'onResourceStart'. 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