DhrJay Posted December 21, 2012 Share Posted December 21, 2012 Hey guys! Can someone please tell me what I did wrong? This is my carristriction.lua: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() armySkins = { [287]=true, [217]=true} armycars = { [432]=true, [520]=true, [425]=true, [548]=true } end ) function enterVehicle ( thePlayer, seat, jacked ) if ( armycars[getElementModel ( source )] ) and ( not armySkins[getElementModel ( thePlayer )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only army members can drive this car!", thePlayer ) end end This is my meta.xml: <meta> <script src="rrtrucker_server.lua" /> </meta> Link to comment
Smart. Posted December 21, 2012 Share Posted December 21, 2012 There's no eventhandler attached to the function. Link to comment
DhrJay Posted December 21, 2012 Author Share Posted December 21, 2012 There's no eventhandler attached to the function. Hey! Thanks for the quick reply... But the first line says: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), What's the right way to do it? I'm learning LUA so, be patient please... Link to comment
Mefisto_PL Posted December 21, 2012 Share Posted December 21, 2012 https://wiki.multitheftauto.com/wiki/OnVehicleEnter in meta <script src="rrtrucker_server.lua" type="server"/> Link to comment
Fury Posted December 22, 2012 Share Posted December 22, 2012 armySkins = { 287, 217 } armycars = { 432, 520, 425, 548 } function enterVehicle ( theVehicle, seat, jacked ) if ( armycars[getElementModel ( theVehicle )] ) and ( not armySkins[getElementModel ( source )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only army members can drive this car!", source ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- this is the event. Link to comment
Baseplate Posted December 22, 2012 Share Posted December 22, 2012 This is my carristriction.lua:This is my meta.xml: <meta> <script src="rrtrucker_server.lua" /> </meta> You made it wrong, should be this <meta> <script src="carristriction.lua" /> </meta> Link to comment
DhrJay Posted December 24, 2012 Author Share Posted December 24, 2012 Thanks all! I have this now..But it still doesn't work... carristriction.lua: armySkins = { 287, 217 } armycars = { 432, 520, 425, 548 } function enterVehicle ( theVehicle, seat, jacked ) if ( armycars[getElementModel ( theVehicle )] ) and ( not armySkins[getElementModel ( source )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only army members can drive this car!", source ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- this is the event. Meta.xml <meta> <script src="carristriction.lua" /> </meta> Link to comment
Castillo Posted December 24, 2012 Share Posted December 24, 2012 That's because of how you made the table, also, 'source' of 'onVehicleEnter' is the vehicle element, not the player who entered. armySkins = { [ 287 ] = true, [ 217 ] = true } armycars = { [ 432 ] = true, [ 520 ] = true, [ 425 ] = true, [ 548 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( armycars [ getElementModel ( source ) ] ) and ( not armySkins [ getElementModel ( thePlayer ) ] ) and ( seat == 0 ) then cancelEvent ( ) outputChatBox ( "Only army members can drive this car!", thePlayer ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- this is the event. Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 That's because of how you made the table, also, 'source' of 'onVehicleEnter' is the vehicle element, not the player who entered. armySkins = { [ 287 ] = true, [ 217 ] = true } armycars = { [ 432 ] = true, [ 520 ] = true, [ 425 ] = true, [ 548 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( armycars [ getElementModel ( source ) ] ) and ( not armySkins [ getElementModel ( thePlayer ) ] ) and ( seat == 0 ) then cancelEvent ( ) outputChatBox ( "Only army members can drive this car!", thePlayer ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- this is the event. Hey man! Thanks! This still doesnt work though... The server doesnt even find the resource... -Jay Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 Why not? what does it say on the console? Link to comment
Tete omar Posted December 26, 2012 Share Posted December 26, 2012 That's because of how you made the table, also, 'source' of 'onVehicleEnter' is the vehicle element, not the player who entered. armySkins = { [ 287 ] = true, [ 217 ] = true } armycars = { [ 432 ] = true, [ 520 ] = true, [ 425 ] = true, [ 548 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( armycars [ getElementModel ( source ) ] ) and ( not armySkins [ getElementModel ( thePlayer ) ] ) and ( seat == 0 ) then cancelEvent ( ) outputChatBox ( "Only army members can drive this car!", thePlayer ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- this is the event. armySkins = { [ 287 ] = true, [ 217 ] = true } armycars = { [ 432 ] = true, [ 520 ] = true, [ 425 ] = true, [ 548 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( armycars [ getElementModel ( source ) ] ) and ( not armySkins [ getElementModel ( thePlayer ) ] ) and ( seat == 0 ) then cancelEvent ( ) outputChatBox ( "Only army members can drive this car!", thePlayer ) end end addEventHandler("onVehicleStartEnter", root, enterVehicle ) Event onVehicleEnter could not be canceled , onVehicleStartEnter could be Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 My bad, I didn't notice it was wrong event used. Link to comment
Tete omar Posted December 26, 2012 Share Posted December 26, 2012 My bad, I didn't notice it was wrong event used. No problem , nobody is perfect , i always forget the 'end' and the brackets tbh Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 Why not? what does it say on the console?\Well, that's the problem... It doesn't say anything at all... It says: start: Resource could not be found. Maybee it's my META: <meta> <script src="server.lua"/> </meta> Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 Try writing "refresh" on the server console. Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 Try writing "refresh" on the server console. Done. No effect... Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 Are you completely sure that you put it on the right folder? is it a folder or a zip? Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 Are you completely sure that you put it on the right folder? is it a folder or a zip? YOU F****ING MADE IT! HOW DO YOU KNOW THESE THINGS...! I made it a ZIP file, and now it works... Really, where did you learn all this? I really want to start learning scripting too... But it's very hard for me to understand it... Do you have any URL where I could start? (Exept for the MTA scripting tutorials.. ) (PS: Why does it make such a big difference between a normal folder?!) Tnkx, Jay Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 Actually, folders also work, I got most of my scripts on folders, the only thing that doesn't work is rar. Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 Actually, folders also work, I got most of my scripts on folders, the only thing that doesn't work is rar. Strange...But thanks anyways...! Do you know how I could add colors to the message? #EE0000 Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 Define the color of outputChatBox, and set to 'true' the last argument of it. Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 Define the color of outputChatBox, and set to 'true' the last argument of it. Like this? outputChatBox ( "#EE0000 Only army members can drive this car!, true", thePlayer ) Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 outputChatBox ( "#EE0000 Only army members can drive this car!", thePlayer, 255, 255, 255, true ) I said on the last argument, not a comma and 'true' on the string Link to comment
DhrJay Posted December 26, 2012 Author Share Posted December 26, 2012 outputChatBox ( "#EE0000 Only army members can drive this car!", thePlayer, 255, 255, 255, true ) I said on the last argument, not a comma and 'true' on the string Hahaha! you see... I'm a newbie...! Thanks man...Won't bother you any longer (for today )... 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