Convert GG4 wins to GG5

Discussion about Custom Addons for GG5

Convert GG4 wins to GG5

Postby PitBull » Thu Nov 20, 2008 8:08 pm

Someone of you maybe already read it in some other posts that I am writing on a wins-converter for GG4 to GG5.

Currently I'm stuck! My Problem is the following:
I open the old database with:
es.sql('open', 'gg_database', '|gungame4/db')

So far, so good. Now I'm getting all the data of the gg_players table:

es.sql('query', 'gg_database', 'gg4c_db', 'SELECT * FROM gg_players')

Also no error, still looks good for me. Now I close the database:

es.sql('close', 'gg_database')

First part is done. Now I want to get each player of the database-data and import it in the GG5 dict_winners-array.
I tried it like the following:

for steamid in gg4c_db[steamid]:
    dict_winners[steamid]['name'] = gg4c_db[name]
    dict_winners[steamid]['wins'] = gg4c_db[wins]

Here the errors start.

File "/home/css/jb/cstrike/addons/eventscripts/gungame/custom_addons/gg_gg4_convert/gg_gg4_convert.py", line 61, in convert
             for steamid in gg4c_db[steamid]:
UnboundLocalError: local variable 'steamid' referenced before assignment

There is a error with gg4c_db[steamid].
In this moment I asked myself an important question: If I get the complete data out of the database, how is it safed in the keygroup?
After this question, I asked me another: I said Keygroup... do I work the same way with a keygroup like with an array? Hmm, lets ask the ESP-Wiki.
So I searched for keygroup, but all I got was a reference to the ESS-Wiki which didn't helped me.

Maybe you can help me?
Best Regards, PitBull
Saul: If I see a server where I have to download music, I quit instantly, set cl_download_filer all then find another server.
crazypip666: Wait, so you don't actually play GunGame?
Don: Owned!
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Postby RideGuy » Thu Nov 20, 2008 8:13 pm

Change it to:
for steamid in gg4c_db:
    dict_winners[steamid]['name'] = gg4c_db[name]
    dict_winners[steamid]['wins'] = gg4c_db[wins]

I have never worked with sql but it looks like you are on the right track. If you get this to work we would love to add it to gg_convert.


Thanks,
RideGuy
RideGuy

Site Admin
Site Admin
User avatar
 
Posts: 201
Joined: Sat Sep 06, 2008 11:30 am

Postby PitBull » Thu Nov 20, 2008 8:22 pm

I'll give it a try. Thanks

~PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Postby PitBull » Fri Nov 21, 2008 1:43 pm

I tried it, but it doesn't work at all. I think the problem is that the result of the SQL-query is saved in a keygroup, not in an array. I edited the code the following:
    es.sql('open', 'gg_database', '|gungame4/db')
    es.sql('query', 'gg_database', 'gg4c_db', 'SELECT * FROM gg_players')
    es.sql('close', 'gg_database')
    for steamid in gg4c_db:
        dict_winners[steamid]['name'] = gg4c_db['name']
        dict_winners[steamid]['wins'] = gg4c_db['wins']
        gungamelib.saveWinnerDatabase()
    else:
        es.log('Error: Can not run the for-loop!')

And the error came. So ES/Python isn't running the loop at all. Maybe this helps you...

Best Regards, PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Postby RideGuy » Fri Nov 21, 2008 2:36 pm

If you post a GG4 database I'll give it a shot.

Thanks,
RideGuy
RideGuy

Site Admin
Site Admin
User avatar
 
Posts: 201
Joined: Sat Sep 06, 2008 11:30 am

Re: Convert GG4 wins to GG5

Postby PitBull » Fri Nov 21, 2008 3:09 pm

Here you go ;)

Best Regards, PitBull
Attachments
es_gg_database.zip
GG4 Database
(47.43 KiB) Downloaded 898 times
Saul: If I see a server where I have to download music, I quit instantly, set cl_download_filer all then find another server.
crazypip666: Wait, so you don't actually play GunGame?
Don: Owned!
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Postby Warren » Fri Nov 21, 2008 6:21 pm

We have added a GunGame4 converter based off of that code you started PitBull. Thanks for the help!

http://code.google.com/p/gungame-python ... tail?r=553
Warren

Site Admin
Site Admin
 
Posts: 772
Joined: Fri Sep 05, 2008 2:59 am
Location: Boston, MA
Xfire Name: WMA9000

Postby PitBull » Fri Nov 21, 2008 6:30 pm

I'm glad you did it! I'm also very impressed how you realised it ;)
Maybe you should check if the database exists. The ESP-Wiki says that the server may crash if the keygroup is deleted before running this command. And not existing equals to removed in my eyes ;).
ESP-Wiki wrote:May crash the server if the KeyValues instance is referenced after the keygroup is removed.


~PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Re:

Postby Saul » Sat Nov 22, 2008 11:32 am

PitBull wrote:And not existing equals to removed in my eyes ;).


Nah. KeyValues doesn't work like that. It uses pointers to KeyValues. If the KeyValues is removed, you now have a NULL pointer -- that will cause a crash.
Saul

GunGame5 Developer
GunGame5 Developer
 
Posts: 147
Joined: Sun Sep 07, 2008 3:29 pm
Xfire Name: saul0

Postby PitBull » Sat Nov 22, 2008 12:23 pm

Again I learned something ;)

Thank you,
~PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Re:

Postby Saul » Sun Nov 30, 2008 12:42 am

PitBull wrote:Again I learned something ;)

Thank you,
~PitBull


The more you know...
Saul

GunGame5 Developer
GunGame5 Developer
 
Posts: 147
Joined: Sun Sep 07, 2008 3:29 pm
Xfire Name: saul0



Return to Custom Addons

Who is online

Users browsing this forum: No registered users and 0 guests

cron