yMassai Posted April 6, 2012 Share Posted April 6, 2012 local policeCars = { } -- We create a table. --Create Stuff function testCreateTrainStuff ( ) test_marker_request = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170) createBlip ( 1543.98962, -1670.46398, 13.55753, 41) ped = createPed (280,1543.98962,-1670.46398,13.55753, 90) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) addEventHandler ( "onClientPedDamage", ped, function ( ) cancelEvent ( ) end ) addEventHandler ( 'onMarkerHit', root, function ( uElement ) if source == myMarker then local uTeam = getPlayerTeam ( uElement ) if uTeam and getTeamName( uTeam ) == 'Policia' and getElementModel ( uElement ) == 280 then outputChatBox 'TODO' end end end ) --Create Vehicle function testCreateTest ( ) if ( isElement ( policeCars[ source ] ) ) then -- We check if the player already has a car spawned. destroyElement ( policeCars[ source ] ) -- If so, we destroy it. end policeCars[ source ] = createVehicle ( 596, 1535.05615, -1675.60766, 13.56008 ) -- We create the vehicle stored in 'policeCars' table. outputChatBox ("Você virou Policial", source, 255, 0, 0 ) end addEvent ( "testCreateTest", true ) addEventHandler ( "testCreateTest", root, testCreateTest ) --Test Gui function testCreateTestGUI ( hitElement ) if ( source == test_marker_request ) then triggerClientEvent ( hitElement, "testCreateTestGUI", hitElement ) end end addEventHandler ( "onMarkerHit", root, testCreateTestGUI ) How do I get to get a team and a skin, I try but I can not. Link to comment
Castillo Posted April 6, 2012 Share Posted April 6, 2012 getPlayerTeam -- Get player team. getElementModel -- Get element model, in this case a player. Link to comment
yMassai Posted April 6, 2012 Author Share Posted April 6, 2012 (edited) maybe local policeCars = { } -- We create a table. --Create Stuff function testCreateTrainStuff ( ) test_marker_request = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170) createBlip ( 1543.98962, -1670.46398, 13.55753, 41) ped = createPed (280,1543.98962,-1670.46398,13.55753, 90) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) addEventHandler ( "onClientPedDamage", ped, function ( ) cancelEvent ( ) end ) addEventHandler ( 'onMarkerHit', root,) function teamName ( source, key, uElement) local playerTeam = getPlayerTeam ( source ) if ( Policia ) then local oldTeamName = getTeamName ( Policia ) setTeamName ( Policia, uElement ) else local id = getElementModel ( uElement ) if id == 280 then end --Create Vehicle function testCreateTest ( ) if ( isElement ( policeCars[ source ] ) ) then -- We check if the player already has a car spawned. destroyElement ( policeCars[ source ] ) -- If so, we destroy it. end policeCars[ source ] = createVehicle ( 596, 1535.05615, -1675.60766, 13.56008 ) -- We create the vehicle stored in 'policeCars' table. outputChatBox ("Você virou Policial", source, 255, 0, 0 ) end addEvent ( "testCreateTest", true ) addEventHandler ( "testCreateTest", root, testCreateTest ) --Test Gui function testCreateTestGUI ( hitElement ) if ( source == test_marker_request ) then triggerClientEvent ( hitElement, "testCreateTestGUI", hitElement ) end end addEventHandler ( "onMarkerHit", root, testCreateTestGUI ) Edited April 6, 2012 by Guest Link to comment
Castillo Posted April 6, 2012 Share Posted April 6, 2012 No, that won't work, you got a missing "end", maybe something else. Link to comment
yMassai Posted April 6, 2012 Author Share Posted April 6, 2012 You could explain it better? Link to comment
Castillo Posted April 6, 2012 Share Posted April 6, 2012 local policeCars = { } -- We create a table. --Create Stuff function testCreateTrainStuff ( ) test_marker_request = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) createBlip ( 1543.98962, -1670.46398, 13.55753, 41 ) ped = createPed (280,1543.98962,-1670.46398,13.55753, 90 ) addEventHandler ( 'onMarkerHit', test_marker_request, teamName ) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) function teamName ( source, key, uElement) local id = getElementModel ( source ) if ( id == 280 ) then -- Your code here. end end --Create Vehicle function testCreateTest ( ) if ( isElement ( policeCars[ source ] ) ) then -- We check if the player already has a car spawned. destroyElement ( policeCars[ source ] ) -- If so, we destroy it. end policeCars[ source ] = createVehicle ( 596, 1535.05615, -1675.60766, 13.56008 ) -- We create the vehicle stored in 'policeCars' table. outputChatBox ("Você virou Policial", source, 255, 0, 0 ) end addEvent ( "testCreateTest", true ) addEventHandler ( "testCreateTest", root, testCreateTest ) --Test Gui function testCreateTestGUI ( hitElement ) if ( source == test_marker_request ) then triggerClientEvent ( hitElement, "testCreateTestGUI", hitElement ) end end addEventHandler ( "onMarkerHit", root, testCreateTestGUI ) Link to comment
yMassai Posted April 6, 2012 Author Share Posted April 6, 2012 Sorry but I would also like to add a team at the same time , but you withdrew, my example would be right? To add the skin maybe i should add a event. ye? Link to comment
Castillo Posted April 6, 2012 Share Posted April 6, 2012 local policeCars = { } -- We create a table. --Create Stuff function testCreateTrainStuff ( ) test_marker_request = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) createBlip ( 1543.98962, -1670.46398, 13.55753, 41 ) ped = createPed (280,1543.98962,-1670.46398,13.55753, 90 ) addEventHandler ( 'onMarkerHit', test_marker_request, onMarkerHit ) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) function onMarkerHit ( thePlayer ) local id = getElementModel ( thePlayer ) local teamName = getPlayerTeam ( thePlayer ) and getTeamName ( getPlayerTeam ( thePlayer ) ) or false if ( teamName == "Police" and id == 280 ) then -- Your code here. end end --Create Vehicle function testCreateTest ( ) if ( isElement ( policeCars[ source ] ) ) then -- We check if the player already has a car spawned. destroyElement ( policeCars[ source ] ) -- If so, we destroy it. end policeCars[ source ] = createVehicle ( 596, 1535.05615, -1675.60766, 13.56008 ) -- We create the vehicle stored in 'policeCars' table. outputChatBox ("Você virou Policial", source, 255, 0, 0 ) end addEvent ( "testCreateTest", true ) addEventHandler ( "testCreateTest", root, testCreateTest ) --Test Gui function testCreateTestGUI ( hitElement ) if ( source == test_marker_request ) then triggerClientEvent ( hitElement, "testCreateTestGUI", hitElement ) end end addEventHandler ( "onMarkerHit", root, testCreateTestGUI ) Link to comment
yMassai Posted April 6, 2012 Author Share Posted April 6, 2012 [16:36:44] warning: Policia\policia_s.lua:Bad 'player' pointer @ 'getplayerTeam' (1) Link to comment
yMassai Posted April 6, 2012 Author Share Posted April 6, 2012 This information is provided by the console. And the player do not take a skin or a team. 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