[SCRIPT] Random Places Pickup

Started by BigcaT_, Jan 24, 2015, 10:01 AM

Previous topic - Next topic

BigcaT_

:) here is the code :


First you have to add some pickups.. for example :
<Pickup model="383" world="1" x="-349.7074" y=" -535.9243" z="12.7917"/>
<Pickup model="383" world="1" x="-1720.1571" y=" -240.6453" z="14.8683"/>
<Pickup model="383" world="1" x="270.8548" y=" -1308.4232" z="11.0712"/>
<Pickup model="383" world="1" x="-672.8633" y=" 748.8453" z="10.9093"/>
 
<!-- put these to server.conf -->

Next, you should:
function onPickupPickedUp( player, pickup ) NewTimer("randompos",100,50,player.ID,player.Pos.x,player.Pos.y,player.Pos.z+20);
Finally, add this function :

function randompos(player,px,py,pz)
{
    player = FindPlayer(player);
    if (player)
    {
        local int_x = px.tointeger(),int_y = py.tointeger(),int_z = pz.tointeger();
        local float_x = random(int_x-100,int_x+101).tofloat(),float_y = random(int_y-100,int_y+101).tofloat(),float_z = random(int_z,int_z+201).tofloat();
        player.Pos = Vector ( float_x,float_y,float_z);
    }
}
function random(start, finish)
{
local t = ((rand() % (finish - start)) + start);
return t;
}

Now it's Okay. ;D :D

Thijn