yMassai Posted March 26, 2012 Share Posted March 26, 2012 (edited) --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) createPed (280,1543.98962,-1670.46398,13.55753, 5.0) setElementFrozen ( ped, true ) end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),testCreateTestStuff) --Create Vehicle function testCreateTest () theTest = createVehicle (596, 1535.05615, -1675.60766, 12.96008) outputChatBox ("Você virou Policial",source, 255, 00, 00) end addEvent ("testCreateTest",true) addEventHandler ("testCreateTest",getRootElement(),testCreateTest) --Test Gui function testCreateTestGUI(hitElement) if source == test_marker_request then triggerClientEvent (hitElement,"testCreateTestGUI",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),testCreateTestGUI) this feature is not working could anyone help me? would also have put to take a team and a skin? this test_s Edited March 26, 2012 by Guest Link to comment
Castillo Posted March 26, 2012 Share Posted March 26, 2012 Would help if you would gives us more information, what is this? what is wrong with it? do you have any debug error(s)? Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 (edited) --Create GUI function testCreateTestGUI() test_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Train Mission",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Nothing",true,test_window_main) test_window_main_button_acceitar = guiCreateButton(0.52,0.85,0.45,0.1,"Aceitar",true,train_window_main) test_window_main_button_sair = guiCreateButton(0,0.85,0.45,0.1,"Sair",true,test_window_main) showCursor (true) end addEvent ("testCreateTestGUI",true) addEventHandler ("testCreateTestGUI",getResourceRootElement(getThisResource()),testCreateTestGUI) --On test Window Click function testOntestWindowClick() if source == test_window_main_button_aceitar then triggerServerEvent ("testCreateTest",getRootElement()) testDestroyTestGUI () elseif source == test_window_main_button_sair then testDestroyTestGUI () end end addEventHandler("onClientGUIClick",getRootElement(),testOnTestWindowClick) these are the data of window. this test_c Edited March 26, 2012 by Guest Link to comment
Castillo Posted March 26, 2012 Share Posted March 26, 2012 Would help if you would gives us more information, what is this? what is wrong with it? do you have any debug error(s)? Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 script error: test\test_s.lua:10: ambiguous syntax (function call x new statement) near '(' warning: loading script failid: test\test_s:10: ambiguous syntax (function call x new statement) near '(' that appears in the console window Link to comment
Castillo Posted March 26, 2012 Share Posted March 26, 2012 -- client side: --Create GUI function testCreateTestGUI ( ) test_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Train Mission",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Nothing",true,test_window_main) test_window_main_button_acceitar = guiCreateButton(0.52,0.85,0.45,0.1,"Aceitar",true,test_window_main) test_window_main_button_sair = guiCreateButton(0,0.85,0.45,0.1,"Sair",true,test_window_main) showCursor ( true ) end addEvent ( "testCreateTestGUI", true ) addEventHandler ( "testCreateTestGUI", root, testCreateTestGUI ) --Destroy GUI function testDestroyTestGUI ( ) if isElement ( test_window_main ) then destroyElement ( test_window_main ) end if isElement ( memo1 ) then destroyElement ( memo1 ) end if isElement ( test_window_main_button_acceitar ) then destroyElement ( test_window_main_button_acceitar ) end if isElement ( test_window_main_button_sair ) then destroyElement ( test_window_main_button_sair ) end showCursor ( false ) end --On test Window Click function testOnTestWindowClick ( ) if ( source == test_window_main_button_acceitar ) then triggerServerEvent ( "testCreateTest", localPlayer ) testDestroyTestGUI ( ) elseif ( source == test_window_main_button_sair ) then testDestroyTestGUI ( ) end end addEventHandler ( "onClientGUIClick", root, testOnTestWindowClick ) -- server side: --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, 5.0) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) --Create Vehicle function testCreateTest ( ) theTest = createVehicle ( 596, 1535.05615, -1675.60766, 12.96008 ) 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 March 26, 2012 Author Share Posted March 26, 2012 error: unzipped\test\test_s.lua:24 attempt to call a boolean value Link to comment
Castillo Posted March 26, 2012 Share Posted March 26, 2012 That's not an error from this script, I've tested it and works perfectly fine. Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 someone could help fix the bug of the car? This script creates more of a car, could you create only one to each player? could be introduced to get the skin 280 and the Police team? Link to comment
Castillo Posted March 26, 2012 Share Posted March 26, 2012 -- server side: 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, 5.0) setElementFrozen ( ped, true ) end addEventHandler ( "onResourceStart", resourceRoot, testCreateTrainStuff ) --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, 12.96008 ) -- 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
Kenix Posted March 26, 2012 Share Posted March 26, 2012 someone could help fix the bug of the car?This script creates more of a car, could you create only one to each player? could be introduced to get the skin 280 and the Police team? You need to learn to fix everything themselves. Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 I'm learning but I'm kind of slow and need to understand well. Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 you could tell me how do I get for a team and a skin in this sript? Link to comment
Kenix Posted March 26, 2012 Share Posted March 26, 2012 getPlayerTeam getElementModel ? Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 yes but I would like to know the development of controls. Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 2012 could you post a snippet with getPlayerTeam and getElementModel. I would like to see an example. Link to comment
drk Posted March 26, 2012 Share Posted March 26, 2012 (edited) addEventHandler ( 'onMarkerHit', root, function ( sPed ) if ( source == sMarker and getPlayerTeam ( sPed ) and getTeamName ( getPlayerTeam ( sPed ) ) == 'Team 1' and getElementModel ( sPed ) == 0 ) then outputChatBox ( 'Awesome.' ); end end ) Edited March 26, 2012 by Guest Link to comment
X-SHADOW Posted March 26, 2012 Share Posted March 26, 2012 Darken why did you type and getPlayerTeam(player) and getPlayerTeam(player) why dont you type it 1 time ? Link to comment
drk Posted March 26, 2012 Share Posted March 26, 2012 Because the first check if the player have team, the second checks if team name is 'Team 1'. Link to comment
Kenix Posted March 26, 2012 Share Posted March 26, 2012 (edited) Function print disabled in mta. Also getPlayerTeam ( player ) == 'Team 1' it's wrong because getPlayerTeam return team element ( not string ). So correct addEventHandler ( 'onMarkerHit', root, function ( uElement ) if source == myMarker and getElementType( uElement ) == 'player' then local uTeam = getPlayerTeam ( uElement ) if uTeam and getTeamName( uTeam ) == 'Team 1' and getElementModel ( uElement ) == 0 then outputChatBox 'TODO' end end end ) Edited March 26, 2012 by Guest Link to comment
yMassai Posted March 26, 2012 Author Share Posted March 26, 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 ( "onClientPedDamage", ped, cancelEvent ) addEventHandler ( "onResourceStart", resourceRoot, testCreateTestStuff ) addEventHandler ( 'onMarkerHit', root, function ( uElement ) if source == myMarker then local uTeam = getPlayerTeam ( uElement ) if uTeam and getTeamName( uTeam ) == 'Policia' and getElementModel ( player ) == 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, 12.96008 ) -- 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 ) would look like this for example? or I put in the wrong place? Link to comment
drk Posted March 26, 2012 Share Posted March 26, 2012 Function print disabled in mta. Also getPlayerTeam ( player ) == 'Team 1' it's wrong because getPlayerTeam return team element ( not string ). So correct addEventHandler ( 'onMarkerHit', root, function ( uElement ) if source == myMarker and getElementType( uElement ) == 'player' then local uTeam = getPlayerTeam ( uElement ) if uTeam and getTeamName( uTeam ) == 'Team 1' and getElementModel ( uElement ) == 0 then outputChatBox 'TODO' end end end ) I ever forget something -.- Link to comment
drk Posted March 26, 2012 Share Posted March 26, 2012 (edited) 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, 12.96008 ) -- 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 March 26, 2012 by Guest 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