ID:1530955
 
(See the best response by Pirion.)
I wanted to create promotions in my game, with the Following scheme: he paid, after I sent the code example D342FvY2 he typed it into an input and earned what he bought, but did not want to shut down the game compiles and get back in the online world
Would these be promotions all in-game or for the BYOND subscription system? For the subscription system, this would be a feature request.

If in-game, you can just store them in a list and add new elements to that list as needed:

var/list/promocodes = list("AAAA")

mob/verb/AddPromoCode(t as text)
promocodes += t
It would probably be wise to randomize the promo codes using 8 characters (num or text). Then make a check to see if an existing promo code was already used; If so, have it generate a new code, etc...
If you use some simple Export() and php, you can have it set so when they purchase a code online, PHP will generate the code and will add it to a .txt document.

There will be another .txt document for the previously entered codes too, so you don't get duplicates.

(An Alternative to this could be MySQL)

When the user enters the promo code in Dream Seeker(your game), use the code
world.Export("http://www.yoursite.com/promocode.php?action=confirm&code=[entered_text]")


and say you have a file called "promocode.php" on your website.

Use the $_GET['action'] and the $_GET['code'] to see what to do to pass the "GET" arguments, well read the "GET" arguments.

Check if the code exists in the .txt document with the available codes but not in the .txt document for the previously generated codes.

If the above is true, they get the promo code bonus whatever and add the code they entered to the previously generated code, otherwise don't give it to them because they are trying to cheat or entered a previously used code.
Hi there :P Well, i'm assuming that you want the player to buy the code with in-game money. This should work:

mob/player
var
money= 100
Cheat_Code = "0"
var/list/codes = list()

mob/player/verb/buyCode()
var/i = input("This will cost you 50gold, do you wan't to proceed?")in list("Yes","No")
if(i=="Yes")
if(src.money>=50)
src.money -= 50

for(var/u=0, u<6, u++)
var/b=pick(list("1","2","3","4","5","6","a","A","h","H"))
src.Cheat_Code +=b

alert("Your code is: [src.Cheat_Code]")
src.codes += src.Cheat_Code

Cheat_Code = "0"




mob/player/verb/Inset_Code(n as text)
if (n in src.codes)
alert("CODE APROVED")

else
alert("CODE DECLIENED")


I hope that I could help
,MistY,
In response to Misticone
Misticone wrote:
Hi there :P Well, i'm assuming that you want the player to buy the code with in-game money. This should work:

mob/player
> var
> money= 100
> Cheat_Code = "0"
> var/list/codes = list()
>
> mob/player/verb/buyCode()
> var/i = input("This will cost you 50gold, do you wan't to proceed?")in list("Yes","No")
> if(i=="Yes")
> if(src.money>=50)
> src.money -= 50
>
> for(var/u=0, u<6, u++)
> var/b=pick(list("1","2","3","4","5","6","a","A","h","H"))
> src.Cheat_Code +=b
>
> alert("Your code is: [src.Cheat_Code]")
> src.codes += src.Cheat_Code
>
> Cheat_Code = "0"
>
>
>
>
> mob/player/verb/Inset_Code(n as text)
> if (n in src.codes)
> alert("CODE APROVED")
>
> else
> alert("CODE DECLIENED")


I hope that I could help
,MistY,

Nice snippet except I can use the promotional code infinitely!
Oh yeah, you're completly correct. Hummmm maybe this solves the problem (so the code can only be used one)

mob/player/verb/Inset_Code(n as text)
if (n in src.codes)
alert("CODE APROVED")
src.codes -=n //THIS WILL MAKE SURE THAT THE CODE CAN ONLY BE USED ONCE

else
alert("CODE DECLIENED")


Thanks,
,MistY,
Best response
Once again this code is buggy.

Alert() doesn't return until Ok is clicked. You can enter it as many times as you like, then hit Ok on the alert and it will be accepted multiple times.
In response to Ssj4justdale
Ssj4justdale wrote:
If you use some simple Export() and php, you can have it set so when they purchase a code online, PHP will generate the code and will add it to a .txt document.

There will be another .txt document for the previously entered codes too, so you don't get duplicates.

(An Alternative to this could be MySQL)

When the user enters the promo code in Dream Seeker(your game), use the code
world.Export("http://www.yoursite.com/promocode.php?action=confirm&code=[entered_text]")

and say you have a file called "promocode.php" on your website.

Use the $_GET['action'] and the $_GET['code'] to see what to do to pass the "GET" arguments, well read the "GET" arguments.

Check if the code exists in the .txt document with the available codes but not in the .txt document for the previously generated codes.

If the above is true, they get the promo code bonus whatever and add the code they entered to the previously generated code, otherwise don't give it to them because they are trying to cheat or entered a previously used code.


There is another solution without using MySQL? something like promocodes.ini
.ini is just a text file. You can write them into a BYOND save file, a text file, or any other type of file. Sqlite would work too, which is now naively in BYOND.

You have to trust your host for this though.
In response to Gabriel001
Gabriel001 wrote:
Ssj4justdale wrote:
If you use some simple Export() and php, you can have it set so when they purchase a code online, PHP will generate the code and will add it to a .txt document.

There will be another .txt document for the previously entered codes too, so you don't get duplicates.

(An Alternative to this could be MySQL)

When the user enters the promo code in Dream Seeker(your game), use the code
world.Export("http://www.yoursite.com/promocode.php?action=confirm&code=[entered_text]")

and say you have a file called "promocode.php" on your website.

Use the $_GET['action'] and the $_GET['code'] to see what to do to pass the "GET" arguments, well read the "GET" arguments.

Check if the code exists in the .txt document with the available codes but not in the .txt document for the previously generated codes.

If the above is true, they get the promo code bonus whatever and add the code they entered to the previously generated code, otherwise don't give it to them because they are trying to cheat or entered a previously used code.


There is another solution without using MySQL? something like promocodes.ini

Message me on Skype @ [email protected] and I can assist you much faster since this may require a bit of explaining.
I need help!!!!!!!!
In response to Gabriel001
Gabriel001 wrote:
I need help!!!!!!!!

I knew Dale wasn't up for it... Well, what do you need? We the BYOND Community are here for you.
I have a nice PayPal library you could use, it using PayPal's IPN and inserts into a MySQL database, from there the user can pay for gold in games items etc...
ATHK can you send it to me too, I'll be interested in it. :)
Sent, had to fix up the IPN code to make it more future proof.
A.T.H.K can you send this to me as well? I've always wanted to learn and more or less try to get the grip on how such process works.
PayPal has it's API's listed as well as various documentations to explain how you could integrate the service; you all don't have to hound him for his implementation if you just knew how to program.
You know, there are quite a number of ways to aid somebody who is in search for help. You obviously can't refrain from insulting somebody who doesn't have the same knowledge as yourself. This is quite unnecessary as this is under "Developer Help" section for a reason which you clearly don't, or simply refuse to recognize.

Going by your logic nobody should ask for help here because everything you could possibly need help in will already be documented..

In the end, this is obviously ATHK's decision, but I am quite irritated by your response.
^ KingDeity is just trying to hound people because they got nothing better to do with there life, please pay no attention to them.

I agree with you very much though FishMan123.
Page: 1 2