drk Posted March 29, 2012 Posted March 29, 2012 Anyway, your code is wrong. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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? EPT Team Server Development: 0% Learning C++ | C++ is amazing
DNL291 Posted March 29, 2012 Posted March 29, 2012 Anyway, your code is wrong. you tested? it worked for me Please do not PM me with scripting related question nor support, use the forums instead.
Moderators IIYAMA Posted March 29, 2012 Moderators Posted March 29, 2012 https://community.multitheftauto.com/index.php?p= ... ls&id=1474 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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. Please do not PM me with scripting related question nor support, use the forums instead.
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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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 Please do not PM me with scripting related question nor support, use the forums instead.
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) EPT Team Server Development: 0% Learning C++ | C++ is amazing
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 Please do not PM me with scripting related question nor support, use the forums instead.
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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
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 Please do not PM me with scripting related question nor support, use the forums instead.
Alpha Posted March 29, 2012 Posted March 29, 2012 Your code is simply fucked up, doesn't need testing or glasses to see that. My Resources: [REL] Support System v1.0.2
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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
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. Please do not PM me with scripting related question nor support, use the forums instead.
drk Posted March 29, 2012 Posted March 29, 2012 And the answer is: YOUR CODE DOESN'T WORKS. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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 Please do not PM me with scripting related question nor support, use the forums instead.
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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
yMassai Posted March 30, 2012 Author Posted March 30, 2012 Omg not work! Maybe a error in create the pickup... Community Profile MTA:SA = Click Here
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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
DNL291 Posted March 30, 2012 Posted March 30, 2012 need to cancel the event for other skins not catch the pickup Please do not PM me with scripting related question nor support, use the forums instead.
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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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