Zokan Posted January 14, 2012 Posted January 14, 2012 Hello people I have a few questions 1.I am looking for a script that takes away someone's jetpack when he flies into a specific area or as long as he's in there also may get none at all .... Is there such a script? 2. I've created a script. It should create a Col or delete the Col with a command. The delete works but does not create the why? Here's the script: g_base_col = createColCuboid ( 130.09884643555, -2079.8127441406, -10, 250, 300, 500 ) function colhin ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then destroyElement ( g_base_col ) end end end addCommandHandler ( "set", colhin ) function colhin1 ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then g_base_col = createColCuboid ( 130.09884643555, -2079.8127441406, -10, 250, 300, 500 ) end end end addCommandHandler ( "set1", colhin1 ) MFG Zokan
myonlake Posted January 14, 2012 Posted January 14, 2012 Commands /createcol - creates a colCuboid /deletecol - deletes a colCuboid that was created before function createCol(player, cmd) if getElementType(player) == "player" then if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then if not g_base_col then g_base_col = createColCuboid(130.09884643555, -2079.8127441406, -10, 250, 300, 500) else outputChatBox("Error happened: collision shape is already created, delete it first.", player, 255, 0, 0, false) end end end end addCommandHandler("createcol", createCol) function deleteCol(player, cmd) if getElementType(player) == "player" then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then if g_base_col then destroyElement(g_base_col) else outputChatBox("Error happened: collision shape is not created yet.", player, 255, 0, 0, false) end end end end addCommandHandler("deletecol", deleteCol)
Xeno Posted January 14, 2012 Posted January 14, 2012 https://wiki.multitheftauto.com/wiki/OnColShapeHit https://wiki.multitheftauto.com/wiki/RemovePedJetPack
Zokan Posted January 14, 2012 Author Posted January 14, 2012 That does not work with the jetpack he does not get it taken away Here's my script: function hit ( pla, source ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) if ( doesPedHaveJetPack ( source ) ) then removePedJetPack ( source ) outputChatBox ( "***Admin Area***", pla, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." has entered the Admin Area!", g_root, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." please left the Admin Area!", pla, 255, 0, 0 ) end end end end addEventHandler ( "onColShapeHit", g_base_col, hit ) error message: Warning: test/test.lua:42: Bad argument @ ´doesPedHaveJetPack`
GanJaRuleZ Posted January 14, 2012 Posted January 14, 2012 function hit ( pla, source ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) outputChatBox ( "***Admin Area***", pla, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." has entered the Admin Area!", g_root, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." please left the Admin Area!", pla, 255, 0, 0 ) end end end end addEventHandler ( "onColShapeHit", g_base_col, hit ) try it , changed from source -- to pla
Zokan Posted January 14, 2012 Author Posted January 14, 2012 thanks it works does it also somehow you can not then get the jetpack as long as you are in the Col? MFG Zokan
codeluaeveryday Posted January 14, 2012 Posted January 14, 2012 make a settimer to check every 1 second if the player has a jetpack. setTimer() doesPedHaveJetPack() removePedJetPack() aka. setTimer( function timer() if doesPedHaveJetPack(getLocalPlayer()) then removePedJetPack(getLocalPlayer()) end end ,1000,0 )
Zokan Posted January 14, 2012 Author Posted January 14, 2012 ok I have it now so every second but then comes an error message can someone help me pls would be nice:) Script: function jetweg( pla, source ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then else if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) end end end end addEventHandler ( "onColShapeHit", g_base_col, jetweg ) setTimer( jetweg, 1000,0 )
Fabio(GNR) Posted January 14, 2012 Posted January 14, 2012 I think a timer is unfunctional, on giving jetpack you should check if the ped is in the colshape with https://wiki.multitheftauto.com/wiki/IsE ... inColShape like function givejet(source) if isElementWithinColShape(source,nameofcol) == false then giveJetPack(source) end end This is just a rough version which doesnt work but shows the concept
Zokan Posted January 14, 2012 Author Posted January 14, 2012 I have it now so I can still get a jetpack in the Col. Error messages are not ... function ColShapeHit ( thePlayer, matchingDimension ) local detection = isElementWithinColShape ( thePlayer, g_base_col ) if detection then if ( doesPedHaveJetPack ( thePlayer ) ) then removePedJetPack ( thePlayer ) end end end addEventHandler ( "onColShapeHit", g_base_col, ColShapeHit )
mjau Posted January 14, 2012 Posted January 14, 2012 function ColShapeHit ( thePlayer, matchingDimension ) local detection = isElementWithinColShape ( thePlayer, g_base_col ) if detection then if ( doesPedHaveJetPack ( thePlayer ) ) then removePedJetPack ( thePlayer ) end end end addEventHandler ( "onClientRender", ColShapeHit ) Try this
GanJaRuleZ Posted January 14, 2012 Posted January 14, 2012 (edited) function ColShapeHit ( thePlayer, matchingDimension ) if isElementWithinColShape(source,nameofcol) == true then if ( doesPedHaveJetPack ( thePlayer ) ) then removePedJetPack ( thePlayer ) end end end addEventHandler ( "onClientRender", ColShapeHit ) Edited January 14, 2012 by Guest
Fabio(GNR) Posted January 14, 2012 Posted January 14, 2012 Uhm. where do you give your jetpack to players? how can they get it? can you copy that script? You should check if they are in the col, when you give the jetpack ( with you i mean the server/script etc.)
GanJaRuleZ Posted January 14, 2012 Posted January 14, 2012 Edited , i pressed accidentaly submit instead of Full Editor
mjau Posted January 14, 2012 Posted January 14, 2012 Yeh anyway zokan use ganjarulez code it should work and is better than what i posted ...
GanJaRuleZ Posted January 14, 2012 Posted January 14, 2012 function hit ( pla, source ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) outputChatBox ( "***Admin Area***", pla, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." has entered the Admin Area!", g_root, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." please left the Admin Area!", pla, 255, 0, 0 ) end end end end addEventHandler ( "onColShapeHit", g_base_col, hit ) function ColShapeHit ( thePlayer, matchingDimension ) if isElementWithinColShape(source,g_base_col) == true then if ( doesPedHaveJetPack ( thePlayer ) ) then removePedJetPack ( thePlayer ) end end end addEventHandler ( "onClientRender", ColShapeHit ) -- Complete script REMEMBER:SERVER-SIDE
Zokan Posted January 14, 2012 Author Posted January 14, 2012 sry fabi who can get the jetpack over j function giveJP() if not doesPedHaveJetPack(g_Me) then server.givePedJetPack(g_Me) guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), true) else server.removePedJetPack(g_Me) guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), false) end end bindKey('j', 'down', giveJP) but it this script not work: function ColShapeHit ( thePlayer, matchingDimension ) if isElementWithinColShape(source,g_base_col) == true then if ( doesPedHaveJetPack ( thePlayer ) ) then removePedJetPack ( thePlayer ) end end end addEventHandler ( "onClientRender", ColShapeHit )
GanJaRuleZ Posted January 14, 2012 Posted January 14, 2012 function hit ( pla, source ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) outputChatBox ( "***Admin Area***", pla, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." has entered the Admin Area!", g_root, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." please left the Admin Area!", pla, 255, 0, 0 ) end end end end addEventHandler ( "onColShapeHit", g_base_col, hit ) function ColShapeHit ( thePlayer, matchingDimension ) if getElementType ( pla ) == "player" then if isElementWithinColShape(pla,g_base_col) == true then if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) end end end addEventHandler ( "onClientRender", ColShapeHit ) try it
Zokan Posted January 14, 2012 Author Posted January 14, 2012 it come an error message: WARNING: test/ad_base_s.lua:51: Bad argument @ ' addEventHandler' [Expected element at argument 2, got function]
Castillo Posted January 14, 2012 Posted January 14, 2012 function hit ( pla ) if (getElementType ( pla ) == "player") then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) else setElementData ( pla, "inRestrictedArea", "true" ) triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) end outputChatBox ( "***Admin Area***", pla, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." has entered the Admin Area!", g_root, 255, 0, 0 ) outputChatBox ( "* "..getPlayerName(pla).." please leave the Admin Area!", pla, 255, 0, 0 ) end end end addEventHandler ( "onColShapeHit", g_base_col, hit )
Zokan Posted January 14, 2012 Author Posted January 14, 2012 No one can come and get the jetpack and it just happens nothing: function ColShapeHit ( thePlayer, matchingDimension ) if getElementType ( pla ) == "player" then if isElementWithinColShape(pla,g_base_col) == true then if ( doesPedHaveJetPack ( pla ) ) then removePedJetPack ( pla ) end end end addEventHandler ( "onClientRender", g_base_col , ColShapeHit ) the other works
Castillo Posted January 14, 2012 Posted January 14, 2012 @GanJaRuleZ: Your script is a total mess, would help if you stop replying, it'll confuse the topic creator. @Zokan: You want to give a jetpack if he player is admin? and if not, remove it?
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