Jump to content
havoc302

Find a random gift system

Recommended Posts

I'm trying to work out the most effective way to create a system ingame where if players find a certain object on the map it'll give them a numeric key which they can then post on our forums to win a gift.

 

So what I'm planning is hiding 50 laptops around the map. If players scroll wheel on them and select to "Check for Gift" they'll either get Rick Astley playing or a randomly generated number in chat. I know how to make it do all these things it's just the random generation of keys and assigning them randomly a single laptop I need. Anyone know of any existing systems that do something similar I could use as an example? Or an easy way to do it?

 

So far I have this which is just the placement:

_positions = [""];

if (isServer) then {
{
_key = random [1111111,5555555,9999999];
"laptopclassname" createVehicle _x;
//Code needed here to somehow assign the number to each laptop and code later to pick one of them as a winner.
} forEach (_x in _positions);

};

diag_log "Laptops placed";

Share this post


Link to post
Share on other sites
Guest

Huh, It's not really random if you assign a known number to a laptop. Because if it's really random how can you link it with a gift ?
For the random thing either add a function on the laptop init or iterate between missionObjects and then use something like

_ran = random 999999;
this setVariable["mynumber",_ran,true]; //We broadcast it to all clients

And then

_ran = laptop getVariable["mynumber",0];
if (_ran < 500000) then {
    hint format ["You loose with the number %1, heres some rick asley to make you understand how unlucky you are :)", _ran];
} else {
    hint format ["Congrats, you won with the code %1. Please enter this code on our website to receive the special Apex Arma 3 toilet paper golden edition prize", _ran];
};
WON_ARR pushback [player, _ran]; // We want to store it in case we want to retrieve it, better call that on server side.
deleteVehicle laptop ;

Share this post


Link to post
Share on other sites

You can either use a list of pre-generated codes which makes it easy to check them on your website. (also allows you to make sure there are no duplicate codes)

 

Or like harmdhast said, you could generate the code directly ingame and log it on the server, for later verification.

 

 

You could also use an extension to send the code directly to your website.

Here's a good example on that:

http://killzonekid.com/arma-extension-url_fetch-dll-v2-0/

 

ps.: I would recommend to log the time, playername and UID together with the code.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a bunch guys, these suggestions are perfect and thanks for even punching out the code for me.

Share this post


Link to post
Share on other sites
Guest

Cleaned it up a bit and added code format.

Share this post


Link to post
Share on other sites

Thanks man!

 

I just read this bit properly, "Please enter this code on our website to receive the special Apex Arma 3 toilet paper golden edition prize" LOL! Totally using it.

Share this post


Link to post
Share on other sites
Guest

Ahah,

Be careful with the second part of the script (This is just some ideas put together nothing that will work correctly). Imo you need to divide this part into the client and the server side.

You can also define a server sided random variable that is your winning var (maybe pick randomly from laptops) and assign a variable on the laptops like

laptop setVariable ["win", true];

or compare directly the value to the one stored server side.

The possibilities are endless.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×