SA-MP Forums Archive
foreach and mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: foreach and mysql (/showthread.php?tid=186655)



foreach and mysql - armyoftwo - 30.10.2010

pawn Код:
public OnGameModeExit()
{
    foreach(Factory, f) { SavePlayerFactory(f); printf("saving: %i",f); }
 ...............................................
pawn Код:
stock SavePlayerFactory(factoryid)
{
    new factoryid2 = FactoryInfo[factoryid][fSQLID];
    format(string, sizeof(string), "UPDATE `factory` SET `X` = '%f', `Y` = '%f', `Z` = '%f', `Owner` = '%i', `Type` = '%i', `Stock` = '%f', `Bank` = '%i', `Lock` = '%i', `ProduceRate` = '%f', `Sell` = '%i' WHERE `SQLID` = '%d'",
        FactoryInfo[factoryid][fPos][0],FactoryInfo[factoryid][fPos][1], FactoryInfo[factoryid][fPos][2],
        FactoryInfo[factoryid][fOwnerID], FactoryInfo[factoryid][fType], FactoryInfo[factoryid][fStock], FactoryInfo[factoryid][fBank], FactoryInfo[factoryid][fLock], FactoryInfo[factoryid][ProduceRate],FactoryInfo[factoryid][fSell]/*FactoryInfo[factoryid][fBank], BusinessInfo[businessid][bSell]*/, factoryid2);
    mysql_query(string);
    mysql_free_result();
}
It doesn't save, it even doesnt print "saving: x"


Re: foreach and mysql - Sergei - 30.10.2010

Gamemode closes before you even process with a single query.
I don't know why are you freeing result since you aren't evne saving it.
I also don't know why do you use '' for floats.
And I really don't know why you save everything when gamemdoe closes. If GF is doing that, it doesn't mean you should do it like that. Save things when they change.


Re: foreach and mysql - armyoftwo - 30.10.2010

Quote:
Originally Posted by Sergei
Посмотреть сообщение
Gamemode closes before you even process with a single query.
I don't know why are you freeing result since you aren't evne saving it.
I also don't know why do you use '' for floats.
And I really don't know why you save everything when gamemdoe closes. If GF is doing that, it doesn't mean you should do it like that. Save things when they change.
How could i know that it's not saving it, and you're totally wrong that i took the idea from GF....
And i am not here to discuss how i script, that's my business how i script

Quote:

And I really don't know why you save everything when gamemdoe closes.

lol you even don't get what i am trying to do here

Suggestion:You should think more before posting false statements..