Forum C# Gift Codes System Help Needed (Resolved!)

Gift Codes System Help Needed (Resolved!)

Postby KotaMills » July 3rd, 2015, 5:43 am

Hello i want to no a simple way using C# to Make a Gift code system were i enter a 1-12 digit code and If the code works it will give me a item
i know how to give items thru C# All'ready but i want to no how to Make Codes and assign items to them and Delete the code from C# when its used

Help And Examples are Appreciated Thanks A'lot!

-Kota 8-)
Last edited by KotaMills on July 9th, 2015, 5:19 pm, edited 2 times in total.
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed

Postby Kp0c » July 3rd, 2015, 12:28 pm

Do the table in BigDB with codes, then (when user try to submit code) check this code from DB (indexes will help). If DB has this code - give item to user and delete code from DB. (Sorry for bad english :( )
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed

Postby KotaMills » July 3rd, 2015, 12:39 pm

I did that and people were hacking like heck lol thats why i posted this in C# i need it on serverside only

but thanks for commenting
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed

Postby Kp0c » July 3rd, 2015, 12:42 pm

KotaMills wrote:I did that and people were hacking like heck lol thats why i posted this in C# i need it on serverside only

but thanks for commenting


You know how he hack your game?
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed

Postby KotaMills » July 3rd, 2015, 12:46 pm

Yea cus DB has to be on Create option To Load Or Create Player Data So he can easyly Create a new Code without DB user and password lol

do you have Facebook maybe.. lol i need instant chat
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed

Postby Kp0c » July 3rd, 2015, 1:06 pm

I dont have FB. Your users connected to any room while enter a code?
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed

Postby KotaMills » July 3rd, 2015, 1:10 pm

Yes i made a Giftcode Room and i made a new C# Class just for it but idk how to programe the C# Giftcode system
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed

Postby Kp0c » July 3rd, 2015, 1:45 pm

Now i dont know :(. If i come up with idea, i write to you
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed (Not Resolved)

Postby KotaMills » July 3rd, 2015, 1:47 pm

Allright all i need is to Have a code on c# and when i enter the code on my game it will call to c# to check if its legit then give me a item or say invalid but only part idk is c# ik how to give items thru c# but idk how to write the Script to make the code Work lol
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed (Not Resolved)

Postby Kp0c » July 3rd, 2015, 2:04 pm

Ok, now i know:
1)Connect user to room.
2)Send to servercode
Code: Select all
Send("Code","1234-5678-9012-wqeq");

3)On servercode check this code:
Code: Select all
public override void GotMessage(Player player, Message message)
        {
            switch (message.Type)
            {
                case "Code":
                    PlayerIO.BigDB.Load("Codes", message.GetString(0), (DatabaseObject obj) =>
                    {
                      //if key there
                      //way #1
                      player.Send("Item","Good item");
                      //way #2 with PayVault
                        player.PayVault.Give(new BuyItemInfo[] {new BuyItemInfo("best item #1"),new BuyItemInfo("best #2"),},() => Console.WriteLine("gived"));
                    }); //i dont know if there an error if key not found. Try experiment
                    break;
            }
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed (Not Resolved)

Postby KotaMills » July 3rd, 2015, 2:14 pm

then in as3 i just Broadcast a msg to c# to get those codes to Start the Checking right
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed (Not Resolved)

Postby KotaMills » July 3rd, 2015, 3:00 pm

lol it worked but even if i enter the wrong code it gives me the item how do i fix that?
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed (Not Resolved)

Postby Kp0c » July 3rd, 2015, 3:53 pm

KotaMills wrote:lol it worked but even if i enter the wrong code it gives me the item how do i fix that?


try to check if obj!=null
Code: Select all
if(obj!=null){
//giveitemcode
}
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed (Not Resolved)

Postby KotaMills » July 3rd, 2015, 5:35 pm

How Do i fix this Error in C#

if u cant view the Screenshot it says

The given key was not present in the dictionary.
at the very end bracket }
Attachments
Screenshot_2.png
Screenshot_2.png (61.36 KiB) Viewed 39956 times
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed (Not Resolved)

Postby Kp0c » July 3rd, 2015, 8:47 pm

KotaMills wrote:How Do i fix this Error in C#

if u cant view the Screenshot it says

The given key was not present in the dictionary.
at the very end bracket }


Change thsi code to
Code: Select all
PlayerIO.BigDB.Load("Codes", message.GetString(0), (DatabaseObject obj) =>
                    {
                        //if key there
                        //way #1
                        player.Send("Item", "Good item");
                        //way #2 with PayVault
                        player.PayVault.Give(new BuyItemInfo[] { new BuyItemInfo("best item #1"), new BuyItemInfo("best #2"), }, () => Console.WriteLine("gived"));
                    },(PlayerIOError error) => Console.WriteLine(error.Message));

I added part with PlayerIOError
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm

Re: Gift Codes System Help Needed (Not Resolved)

Postby KotaMills » July 3rd, 2015, 9:35 pm

Code: Select all
public override void GotMessage(Player player, Message message)
        {
            switch (message.Type)
            {
                case "Code":
                    PlayerIO.BigDB.Load("Codes", message.GetString(0), (DatabaseObject obj) =>
                    {
                        //if key there
                        //way #1
                        //player.Send("Item", "Good item");
                        if (obj.Key != "kota123")
                        {
                            //way #2 with PayVault
                        }
                        else
                        {
                            player.PayVault.Give(new BuyItemInfo[] { new BuyItemInfo("kota"), new BuyItemInfo("kota"), }, () => Console.WriteLine("gived"));
                        }

                    }, (PlayerIOError error) => Console.WriteLine(error.Message));
                    break;
            }
        }



That Right there Should work But how would i do my AS3 Side for that i have it setup but i 100% garuntee you i did my as3 side wrong lol

Code: Select all
private var CheckCode:int;

this.myclient.multiplayer.createJoinRoom(
            "test",                        //Room id. If set to null a random roomid is used
            "bounce",                     //The game type started on the server
            true,                        //Should the room be visible in the lobby?
            {},      //no arguemtns. but it all works tho even on fb                     //Room data. This data is returned to lobby list. Variabels can be modifed on the server
            {code:CheckCode},                           //User join data
            handleJoin,                     //Function executed on successful joining of the room
            handleError                     //Function executed if we got a join error
         );


TheConnection.send("Code", String(CheckCode));
         
      
      TheConnection.addMessageHandler("Code", function(m:Message, _frame:int):void
      {
         
      });
Coming Soon Shark Chase! :D
KotaMills
 
Posts: 30
Joined: December 20th, 2014, 4:22 am

Re: Gift Codes System Help Needed (Not Resolved)

Postby Kp0c » July 3rd, 2015, 9:50 pm

I dont know nothing about AS3 :(
Kp0c
 
Posts: 16
Joined: June 23rd, 2014, 9:29 pm


Return to C#



cron