Jump to content

i need help guys please help me........


Pulsarkk

Recommended Posts

i am beginner(not even a begineer lower than that) of scripting .i had written a script for warzone but its not working

if it works with little changes it gives two or more times money i dont know what to do..

if u wish to help i ll be thank full please.... here is the script

warRadar = createRadarArea (  1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
warShape = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
 
 
function onPlayerShapeHit ( thePlayer, matchingDimension )
 
if ( getElementType ( thePlayer ) == "player" ) then
outputChatBox ( "You have entered War zone!", thePlayer, 255, 0, 0 )
setRadarAreaFlashing ( warRadar, true )
function giveMoney ( killer)
 
 
if ( killer ) and ( killer ~= source )  then
        givemoney( killer ,5000 )
end
end
addEventHandler ( "onPlayerWasted",getRootElement() , giveMoney )
 
end
end
addEventHandler ( "onColShapeHit", warShape, onPlayerShapeHit )
 
function onPlayerShapeLeave ( thePlayer, matchingDimension )   
if ( getElementType ( thePlayer ) == "player" ) then
outputChatBox ( "You have leaved War zone!", thePlayer, 255, 0, 0 )
setRadarAreaFlashing ( warRadar, false )
end
end
addEventHandler ( "onColShapeLeave", warShape, onPlayerShapeLeave )

Link to comment

robhol, but it is allowed ;)

Just tested with a lua binary

function one()
print(1)
function two() 
print(2)
end	
end

I guess it's just declaring another variable inside the function. Would be the same if I did

two = function() print(2) end

But it does work that way and doesn't give errors

And from the first glance his syntax seems to be nice, not like some other people around here (you know who robhol )

Now to helping part:

It seems you started writing it all in one go and got lost while doing it. So first thing you need to do is rethink what you want to do and then do it correctly step by step. There aren't many steps involved here, but still it's easier to code this way.

First, you need to think when and only when will you give money to killer. That means

  • If a player got killed
  • If the killer was in the colshape
  • If the killed was in the colshape

That means you need to add a function which triggers "onPlayerWasted" event (some function and an event handler to trigger it)

warRadar = createRadarArea (  1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 ) -- your radar area
warShape = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 ) -- your colcuboid
 
function giveMoneyToKiller(totalAmmo,killer,killerWeapon,bodyPart) -- check the parameters on wiki, first one is not killer
 
end
addEventHandler("onPlayerWasted",getRootElement(),giveMoneyToKiller)

Now you want to actually make the giveMoneyToKiller work.

So you add checks to see if the player who got killed and the killer were both in the colshape

-- inside giveMoneyToKiller
 
if killer and source ~= killer then -- first you want to check if it's a suicide or something like that.. Don't give money then
if isElementWithinColShape(source,warShape) and isElementWithinColShape(killer,warShape) then -- if both were in colshape
givePlayerMoney(killer,5000) -- again, it's not giveMoney, it's givePlayerMoney, see [url=http://development.mtasa.com/index.php?title=GivePlayerMoney]http://development.mtasa.com/index.php? ... layerMoney[/url]
end
end

Now you don't have to set the war area blinking because it would go blinking for everyone whenever anyone goes into it.

I didn't test the code but it should work. If you don't understand why something goes where, feel free to ask.

If you want adding the blinking then just again, make a function and event handlers pointing to it.

Also you could use debugscript so you can find errors more easily

http://development.mtasa.com/index.php?title=Main_Page

http://development.mtasa.com/index.php?title=Debugging

http://development.mtasa.com/index.php? ... troduction

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...