• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to prevent duplicate entries

Xer0botXer0

Senpai
Hi guys,

so basically I was trying to prevent duplicate entries when receiving data from the server,
well it's still not working grr..

Code:
case 15: ///Receive other player Instance information
   
    //first check that this player data is not already client side
    var get_usn = buffer_read(buffer,buffer_string)
   
    for (qu =0; qu < 10; qu ++)
    {
        if global.arr_other_player_information[qu,0] != get_usn
        {
            inc_qu = inc_qu + 1
        }
    }
   
    if inc_qu >= 9 //player data doesnt already exist
    {
   
        for (qa =0; qa < 10; qa ++) 
        {
            if global.arr_other_player_information[qa,0] == "" //if slot is empty
            {
                ///Populate other player slot with other player information
                global.arr_other_player_information[qa,0] = get_usn //username
                global.arr_other_player_information[qa,1] = -1 //Instance id (use to store instance id upon creation, to use after)
                global.arr_other_player_information[qa,2] = buffer_read(buffer,buffer_u8) //room x
                global.arr_other_player_information[qa,3] = buffer_read(buffer,buffer_u8) //room y
                global.arr_other_player_information[qa,4] = buffer_read(buffer,buffer_u16) //x pos
                global.arr_other_player_information[qa,5] = buffer_read(buffer,buffer_u16) //y pos
                qa = 11 //end
                inc_qu = 0;
            }
        }
     }  
     
   
    break;
any ideas ? i thought this would work.
 
Last edited:

Roa

Member
Hi guys,

so basically I was trying to prevent duplicate entries when receiving data from the server,
it was pretty silly but I figured it out, this required an extra for loop and an integer that increases till the end of the loop, if at the end no duplicates were found(compared two values) then add the new entry after a few other filters.
Maybe try a ds_list??
 
Top