sckatchof Posted March 29, 2012 Posted March 29, 2012 @DNL291 but i ask him what he want he said : " I wanted to create a weapon in a certain place, I would like what only a skins can get the gun."
drk Posted March 29, 2012 Posted March 29, 2012 You want to create a weapon pickup when player dies and only the skins you choose can get them, right?
DNL291 Posted March 29, 2012 Posted March 29, 2012 Anyway, your code is wrong. you tested? it worked for me
Moderators IIYAMA Posted March 29, 2012 Moderators Posted March 29, 2012 https://community.multitheftauto.com/index.php?p= ... ls&id=1474
drk Posted March 29, 2012 Posted March 29, 2012 Good for you. You need start learning Lua DNL291. You're trying destroy player element and some other things that I've not seen. YOUR CODE IS TOTALLY WRONG.
sckatchof Posted March 29, 2012 Posted March 29, 2012 @DNL291 : why u put this ? .. destroyElement( player )
DNL291 Posted March 29, 2012 Posted March 29, 2012 Good for you. You need start learning Lua DNL291. You're trying destroy player element and some other things that I've not seen. only the specified skins can get the pickup. and it is working.
drk Posted March 29, 2012 Posted March 29, 2012 Your server must be magic to run this. Wanna see where are errors in your code? Basically, in all the code.
DNL291 Posted March 29, 2012 Posted March 29, 2012 @DNL291 : why u put this ? .. destroyElement( player ) cancelEvent the pickup will not disappear and the player will not pick up the weapon. destroyElement dont work. Your server must be magic to run this. Wanna see where are errors in your code? Basically, in all the code. then show the error
drk Posted March 29, 2012 Posted March 29, 2012 lockSkins = { [287] = true, [121] = true } function onDeathPickupHit ( player, matchingDimension ) local skin = getElementModel(player) if ( lockSkins[skin] ) then if ( matchingDimension ) then -- no need removeEventHandler ( "onPickupHit", source, onDeathPickupHit ) -- idk if it's needed local weaponPickup = getPickupWeapon( player ) -- wrong destroyElement( player ) -- wrong giveWeapon( player, weapon, false ) -- wrong local weapon = getPedWeapon( player ) -- wrong end else cancelEvent() outputChatBox("*Só militares podem pegar esta arma.", player, 255, 0, 0) end end local function destroyDeathPickup( pickup ) removeEventHandler( "onPickupHit", pickup, onDeathPickupHit ) destroyElement( pickup ) end addEventHandler("onPlayerWasted", root, function (totalammo, killer, killerweapon, bodypart) local timeout = 60000 local x, y, z = getElementPosition( source ) local currentweapon = getPedWeapon( source ) local totalammo = getPedTotalAmmo( source ) local pickup = createPickup( x, y, z, 2, currentweapon, timeout, totalammo ) addEventHandler( "onPickupHit", pickup, onDeathPickupHit ) setTimer( destroyDeathPickup, timeout, 1, pickup ) -- idk why need function end)
DNL291 Posted March 29, 2012 Posted March 29, 2012 (edited) oh, not needed it. location = getPedWeapon weapon (player) if ( matchingDimension ) then destroyElement( player ) removeEventHandler ( "onPickupHit" , origem, onDeathPickupHit ) giveWeapon( player, weapon, false ) but anyway operate normally. Edited March 29, 2012 by Guest
drk Posted March 29, 2012 Posted March 29, 2012 Am? Work? Are you kidding me? You put the code in a file, create a resource, start it and search for errors. No errors, working. Good. STOP SAYING THAT YOUR CODE WORK NORMALLY. YOUR CODE IS TOTALLY WRONG. Learn: viewtopic.php?f=148&t=40809
DNL291 Posted March 29, 2012 Posted March 29, 2012 Am? Work? Are you kidding me? You put the code in a file, create a resource, start it and search for errors. No errors, working. Good. STOP SAYING THAT YOUR CODE WORK NORMALLY. YOUR CODE IS TOTALLY WRONG.Learn: viewtopic.php?f=148&t=40809 why do you say that? does not work for you? arrange and then only post. as I said please post the error that hinders the functioning of the script, as you say
Alpha Posted March 29, 2012 Posted March 29, 2012 Your code is simply fucked up, doesn't need testing or glasses to see that.
drk Posted March 29, 2012 Posted March 29, 2012 I don't need to solve the issues of your code. I posted a working code. Your code is simply up, doesn't need testing or glasses to see that. +1
DNL291 Posted March 29, 2012 Posted March 29, 2012 Your code is simply up, doesn't need testing or glasses to see that. I do not want to know whether it is single or not. the question is whether it works.
DNL291 Posted March 29, 2012 Posted March 29, 2012 And the answer is: YOUR CODE DOESN'T WORKS. as I said please post the error that hinders the functioning of the script, as you say
drk Posted March 29, 2012 Posted March 29, 2012 Dude, I posted the errors of your code. I posted MINE CODE perfectly working. What you need more? Wanna see the full script working?? viewtopic.php?f=91&t=41760&start=15#p422832
yMassai Posted March 30, 2012 Author Posted March 30, 2012 Omg not work! Maybe a error in create the pickup...
Castillo Posted March 30, 2012 Posted March 30, 2012 lockSkins = { [ 287 ] = true, [ 121 ] = true } function onDeathPickupHit ( player ) local skin = getElementModel ( player ) if ( lockSkins[ skin ] ) then destroyDeathPickup ( source ) else cancelEvent ( ) outputChatBox("*Só militares podem pegar esta arma.", player, 255, 0, 0) end end function destroyDeathPickup ( pickup ) if ( isElement ( pickup ) ) then removeEventHandler ( "onPickupUse", pickup, onDeathPickupHit ) destroyElement ( pickup ) end end addEventHandler ( "onPlayerWasted", root, function ( _, killer ) local timeout = 60000 local x, y, z = getElementPosition ( source ) local currentweapon = getPedWeapon ( source ) local totalammo = getPedTotalAmmo ( source ) local pickup = createPickup ( x, y, z, 2, currentweapon, 50, totalammo ) addEventHandler ( "onPickupUse", pickup, onDeathPickupHit ) setTimer( destroyDeathPickup, timeout, 1, pickup ) end )
DNL291 Posted March 30, 2012 Posted March 30, 2012 need to cancel the event for other skins not catch the pickup
drk Posted March 30, 2012 Posted March 30, 2012 need to cancel the event for other skins not catch the pickup if ( lockSkins[ skin ] ) then
drk Posted March 30, 2012 Posted March 30, 2012 lockSkins = { [ 287 ] = true, [ 121 ] = true } function onDeathPickupHit ( player ) local skin = getElementModel ( player ) if ( lockSkins[ skin ] ) then destroyDeathPickup ( source ) else cancelEvent ( ) outputChatBox("*Só militares podem pegar esta arma.", player, 255, 0, 0) end end function destroyDeathPickup ( pickup ) if ( isElement ( pickup ) ) then removeEventHandler ( "onPickupUse", pickup, onDeathPickupHit ) destroyElement ( pickup ) end end addEventHandler ( "onPlayerWasted", root, function ( _, killer ) local timeout = 60000 local x, y, z = getElementPosition ( source ) local currentweapon = getPedWeapon ( source ) local totalammo = getPedTotalAmmo ( source ) local pickup = createPickup ( x, y, z, 2, currentweapon, 50, totalammo ) addEventHandler ( "onPickupUse", pickup, onDeathPickupHit ) setTimer( destroyDeathPickup, timeout, 1, pickup ) end ) Your code doesn't work too. createPickup returns false.
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