04.07.2009, 08:57
Quote:
Originally Posted by gtaplayers
Quote:
|
Originally Posted by gtaplayers
Quote:
|
Originally Posted by Izanagi
ran into another problem with my script. here it is
first, the register doesn't "INSERT INTO `accounts` (`accountName`,`Password`,`EMail`) VALUES ('%s','%s','%s')", aName2, aPass2, aEMail2 note, those are escaped strings. second, whenever my script accesses OnPlayerLogin function it crashes the server. everything is fine if no pasword is given on /login which returns to a client message, but if it's processed into the funciton OnPlayerLogin, it crashes the server. Note that I do not load ALL values yet, this was supposed to be a test |
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE accountName = '%s' AND Password = '%s' LIMIT 1", aName2, aPass2);
mysql_query(query);
mysql_store_result();
// Check if anything was found
if(mysql_num_rows())
{
// rest of login code
}
format(query, sizeof(query), "INSERT INTO `accounts` (accountName,Password,EMail) VALUES ('%s','%s','%s')", aName2, aPass2, aEMail2);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows())
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW, "* [AUTH] Registration Successful! You may now login. ");
else SendClientMessage(playerid, COLOR_LIGHTYELLOW, "* [AUTH] Registration Failed... Please report the error if this continues. ");
}
Originally Posted by ǝɹoɯ‾ʎ
Quote:
pawn Код:
pawn Код:
' ' - String values, (%s) |
Originally Posted by Izanagi
so you mean if I use %d I shouldn't use the ' and '? if it's not varchar? but that way it doesn't work.. ;/
|
Originally Posted by Sneaky.
Tried on 3 different Win2003 servers, all 3 not working.
|
---------- Loaded log file: "server_log.txt". ---------- SA:MP Dedicated Server ---------------------- v0.2X, ©2005-2008 SA:MP Team [18:36:29] [18:36:29] Server Plugins [18:36:29] -------------- [18:36:29] Loading plugin: mysql.so [18:36:29] Failed (/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by plugins/mysql.so)) [18:36:29] Loaded 0 plugins. [18:36:29] [18:36:29] Filter Scripts [18:36:29] --------------- [18:36:29] Loading filter script 'car.amx'... [18:36:29] Loaded 1 filter scripts. [18:36:29] Script[gamemodes/BETA.amx]: Run time error 19: "File or function is not found"
---------- Loaded log file: "server_log.txt". ---------- SA:MP Dedicated Server ---------------------- v0.2X, ©2005-2008 SA:MP Team [10:08:56] [10:08:56] Server Plugins [10:08:56] -------------- [10:08:57] Loading plugin: mysql.dll [10:08:57] Failed. [10:08:57] Loaded 0 plugins. [10:08:57] Script[gamemodes/frpg.amx]: Run time error 19: "File or function is not found" [10:14:05] --- Server Shutting Down. |
mysql_query("SELECT * FROM Anticheat"); mysql_store_result(); count = mysql_num_rows(); mysql_free_result();
Originally Posted by <__Ǝthan__>
Urg, Anyone Know why this isn't working?
Код:
mysql_query("SELECT COUNT(*) FROM Anticheat"); mysql_store_result(); count = mysql_num_rows(); mysql_free_result(); Anyone know why? |
new row[ 10 ]; mysql_query( "SELECT COUNT(*) FROM Anticheat" ); mysql_store_result( ); mysql_fetch_row( row ); count = strval( row ); mysql_free_result( );
public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/mysqltest", cmdtext, true) == 0) { mysql_query("SELECT sleep(10), 55", 5); SendClientMessageToAll(0xFFFFFFFF, "query sent"); return 1; } return 0; } public OnQueryFinish(query[],resultid) { printf("%d: %s", resultid, query); }
Originally Posted by Redirect Left
Hi.
Got a question: Should I open a connection at game mode init, then keep this one connection open until the server is terminated, or should I only open a connection as required? (I.E at login, then kill it as soon as it's got the required data) Secondly; What would happen if say, my server GMX'd, then 20+ people logged in at the same time? Would it mess up, give people the wrong stuff, or what? |
public OnPlayerLogin(playerid,password[]) // by Luk0r v1.0 { MySQLCheckConnection(); new tmp2[256]; new string2[64]; new playername2[MAX_PLAYER_NAME]; new playernamesplit[3][MAX_PLAYER_NAME]; GetPlayerName(playerid, playername2, sizeof(playername2)); split(playername2, playernamesplit, '_'); MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pKey]); if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 ) { new Data[1024]; new Field[64]; new rcnt = 1; MySQLFetchAcctRecord(PlayerInfo[playerid][pSQLID], Data); samp_mysql_strtok(Field, "|", Data); while (samp_mysql_strtok(Field, "|", "")==1) { // The rcnt values here represent the order of the columns in the characters table, so don't mess with them // If you add a column to the table, just add a new line with a +1 rcnt to the block below // Start it at 3 to skip the first few records we don't need (id, player name, password) if (rcnt == 3) PlayerInfo[playerid][pLevel] = strval(Field); if (rcnt == 4) PlayerInfo[playerid][pAdmin] = strval(Field); if (rcnt == 5) PlayerInfo[playerid][pDonateRank] = strval(Field); if (rcnt == 6) PlayerInfo[playerid][gPupgrade] = strval(Field); if (rcnt == 7) PlayerInfo[playerid][pConnectTime] = strval(Field); if (rcnt == 8) PlayerInfo[playerid][pReg] = strval(Field); if (rcnt == 9) PlayerInfo[playerid][pSex] = strval(Field); if (rcnt == 10) PlayerInfo[playerid][pAge] = strval(Field); if (rcnt == 11) PlayerInfo[playerid][pOrigin] = strval(Field); if (rcnt == 12) PlayerInfo[playerid][pCK] = strval(Field); if (rcnt == 13) PlayerInfo[playerid][pMuted] = strval(Field); if (rcnt == 14) PlayerInfo[playerid][pExp] = strval(Field); if (rcnt == 15) PlayerInfo[playerid][pCash] = strval(Field); if (rcnt == 16) PlayerInfo[playerid][pAccount] = strval(Field); if (rcnt == 17) PlayerInfo[playerid][pCrimes] = strval(Field); if (rcnt == 18) PlayerInfo[playerid][pKills] = strval(Field); if (rcnt == 19) PlayerInfo[playerid][pDeaths] = strval(Field); if (rcnt == 20) PlayerInfo[playerid][pArrested] = strval(Field); if (rcnt == 21) PlayerInfo[playerid][pWantedDeaths] = strval(Field); if (rcnt == 22) PlayerInfo[playerid][pPhoneBook] = strval(Field); if (rcnt == 23) PlayerInfo[playerid][pLottoNr] = strval(Field); if (rcnt == 24) PlayerInfo[playerid][pFishes] = strval(Field); if (rcnt == 25) PlayerInfo[playerid][pBiggestFish] = strval(Field); if (rcnt == 26) PlayerInfo[playerid][pJob] = strval(Field); if (rcnt == 27) PlayerInfo[playerid][pPayCheck] = strval(Field); if (rcnt == 28) PlayerInfo[playerid][pHeadValue] = strval(Field); if (rcnt == 29) PlayerInfo[playerid][pJailed] = strval(Field); if (rcnt == 30) PlayerInfo[playerid][pJailTime] = strval(Field); if (rcnt == 31) PlayerInfo[playerid][pMats] = strval(Field); if (rcnt == 32) PlayerInfo[playerid][pDrugs] = strval(Field); if (rcnt == 33) PlayerInfo[playerid][pLeader] = strval(Field); if (rcnt == 34) PlayerInfo[playerid][pMember] = strval(Field); if (rcnt == 35) PlayerInfo[playerid][pFMember] = strval(Field); if (rcnt == 36) PlayerInfo[playerid][pRank] = strval(Field); if (rcnt == 37) PlayerInfo[playerid][pChar] = strval(Field); if (rcnt == 38) PlayerInfo[playerid][pContractTime] = strval(Field); if (rcnt == 39) PlayerInfo[playerid][pDetSkill] = strval(Field); if (rcnt == 40) PlayerInfo[playerid][pSexSkill] = strval(Field); if (rcnt == 41) PlayerInfo[playerid][pBoxSkill] = strval(Field); if (rcnt == 42) PlayerInfo[playerid][pLawSkill] = strval(Field); if (rcnt == 43) PlayerInfo[playerid][pMechSkill] = strval(Field); if (rcnt == 44) PlayerInfo[playerid][pJackSkill] = strval(Field); if (rcnt == 45) PlayerInfo[playerid][pCarSkill] = strval(Field); if (rcnt == 46) PlayerInfo[playerid][pNewsSkill] = strval(Field); if (rcnt == 47) PlayerInfo[playerid][pDrugsSkill] = strval(Field); if (rcnt == 48) PlayerInfo[playerid][pCookSkill] = strval(Field); if (rcnt == 49) PlayerInfo[playerid][pFishSkill] = strval(Field); if (rcnt == 50) PlayerInfo[playerid][pSHealth] = floatstr(Field); if (rcnt == 51) PlayerInfo[playerid][pHealth] = floatstr(Field); if (rcnt == 52) PlayerInfo[playerid][pInt] = strval(Field); if (rcnt == 53) PlayerInfo[playerid][pLocal] = strval(Field); if (rcnt == 54) PlayerInfo[playerid][pTeam] = strval(Field); if (rcnt == 55) PlayerInfo[playerid][pModel] = strval(Field); if (rcnt == 56) PlayerInfo[playerid][pPnumber] = strval(Field); if (rcnt == 57) PlayerInfo[playerid][pPhousekey] = strval(Field); if (rcnt == 58) PlayerInfo[playerid][pPcarkey] = strval(Field); if (rcnt == 59) PlayerInfo[playerid][pPapptkey] = strval(Field); if (rcnt == 60) PlayerInfo[playerid][pPbiskey] = strval(Field); if (rcnt == 61) PlayerInfo[playerid][pPos_x] = floatstr(Field); if (rcnt == 62) PlayerInfo[playerid][pPos_y] = floatstr(Field); if (rcnt == 63) PlayerInfo[playerid][pPos_z] = floatstr(Field); if (rcnt == 64) PlayerInfo[playerid][pCarLic] = strval(Field); if (rcnt == 65) PlayerInfo[playerid][pFlyLic] = strval(Field); if (rcnt == 66) PlayerInfo[playerid][pBoatLic] = strval(Field); if (rcnt == 67) PlayerInfo[playerid][pFishLic] = strval(Field); if (rcnt == 68) PlayerInfo[playerid][pGunLic] = strval(Field); if (rcnt == 69) PlayerInfo[playerid][pGun1] = strval(Field); if (rcnt == 70) PlayerInfo[playerid][pGun2] = strval(Field); if (rcnt == 71) PlayerInfo[playerid][pGun3] = strval(Field); if (rcnt == 72) PlayerInfo[playerid][pGun4] = strval(Field); if (rcnt == 73) PlayerInfo[playerid][pAmmo1] = strval(Field); if (rcnt == 74) PlayerInfo[playerid][pAmmo2] = strval(Field); if (rcnt == 75) PlayerInfo[playerid][pAmmo3] = strval(Field); if (rcnt == 76) PlayerInfo[playerid][pAmmo4] = strval(Field); if (rcnt == 77) PlayerInfo[playerid][pCarTime] = strval(Field); if (rcnt == 78) PlayerInfo[playerid][pPayDay] = strval(Field); if (rcnt == 79) PlayerInfo[playerid][pPayDayHad] = strval(Field); if (rcnt == 80) PlayerInfo[playerid][pCDPlayer] = strval(Field); if (rcnt == 81) PlayerInfo[playerid][pWins] = strval(Field); if (rcnt == 82) PlayerInfo[playerid][pLoses] = strval(Field); if (rcnt == 83) PlayerInfo[playerid][pAlcoholPerk] = strval(Field); if (rcnt == 84) PlayerInfo[playerid][pDrugPerk] = strval(Field); if (rcnt == 85) PlayerInfo[playerid][pMiserPerk] = strval(Field); if (rcnt == 86) PlayerInfo[playerid][pPainPerk] = strval(Field); if (rcnt == 87) PlayerInfo[playerid][pTraderPerk] = strval(Field); if (rcnt == 88) PlayerInfo[playerid][pTut] = strval(Field); if (rcnt == 89) PlayerInfo[playerid][pMissionNr] = strval(Field); if (rcnt == 90) PlayerInfo[playerid][pWarns] = strval(Field); if (rcnt == 91) PlayerInfo[playerid][pAdjustable] = strval(Field); if (rcnt == 92) PlayerInfo[playerid][pFuel] = strval(Field); if (rcnt == 93) PlayerInfo[playerid][pMarried] = strval(Field); if (rcnt == 94) PlayerInfo[playerid][pMarriedTo] = strmid(PlayerInfo[playerid][pMarriedTo], Field, 0, strlen(Field)-1, 255); if (rcnt == 96) PlayerInfo[playerid][pLinked] = strval(Field); if (rcnt == 97) PlayerInfo[playerid][pDeagle] = strval(Field); if (rcnt == 98) PlayerInfo[playerid][pShotgun] = strval(Field); if (rcnt == 99) PlayerInfo[playerid][pRifle] = strval(Field); if (rcnt == 100) PlayerInfo[playerid][pSDPistol] = strval(Field); if (rcnt == 101) PlayerInfo[playerid][pMP5] = strval(Field); if (rcnt == 102) PlayerInfo[playerid][pM4] = strval(Field); if (rcnt == 103) PlayerInfo[playerid][pAK47] = strval(Field); rcnt++; } samp_mysql_free_result(); } else { SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password does not match your name."); //fclose(UserFile); gPlayerLogTries[playerid] += 1; if(gPlayerLogTries[playerid] == 4) { Ban(playerid); } return 1; } PlayerInfo[playerid][pAdjustable] = 0; SafeResetPlayerMoney(playerid); //ConsumingMoney[playerid] = 1; //CurrentMoney[playerid] = PlayerInfo[playerid][pCash]; SafeGivePlayerMoney(playerid,PlayerInfo[playerid][pCash]); SafeGivePlayerWeapon(playerid,24,PlayerInfo[playerid][pDeagle]); SafeGivePlayerWeapon(playerid,25,PlayerInfo[playerid][pShotgun]); SafeGivePlayerWeapon(playerid,33,PlayerInfo[playerid][pRifle]); SafeGivePlayerWeapon(playerid,23,PlayerInfo[playerid][pSDPistol]); SafeGivePlayerWeapon(playerid,29,PlayerInfo[playerid][pMP5]); SafeGivePlayerWeapon(playerid,31,PlayerInfo[playerid][pM4]); SafeGivePlayerWeapon(playerid,30,PlayerInfo[playerid][pAK47]); if(PlayerInfo[playerid][pReg] == 0) { PlayerInfo[playerid][pLevel] = 1; PlayerInfo[playerid][pSHealth] = 0.0; PlayerInfo[playerid][pHealth] = 50.0; PlayerInfo[playerid][pPos_x] = 2246.6; PlayerInfo[playerid][pPos_y] = -1161.9; PlayerInfo[playerid][pPos_z] = 1029.7; PlayerInfo[playerid][pInt] = 15; PlayerInfo[playerid][pLocal] = 255; PlayerInfo[playerid][pTeam] = 3; PlayerInfo[playerid][pModel] = 135; new randphone = 100000 + random(899999);//minimum 1000 max 9999 //giving one at the start PlayerInfo[playerid][pPnumber] = randphone; PlayerInfo[playerid][pPhousekey] = 255; PlayerInfo[playerid][pPcarkey] = 999; PlayerInfo[playerid][pPapptkey] = 255; PlayerInfo[playerid][pPbiskey] = 255; PlayerInfo[playerid][pAccount] = 0; PlayerInfo[playerid][pReg] = 1; SafeGivePlayerMoney(playerid, 500); } if(PlayerInfo[playerid][pLevel] == -999) //autoban { Ban(playerid); } else if(PlayerInfo[playerid][pCK] > 0) { Kick(playerid); } // Add an entry to the login log new ipaddress[16]; GetPlayerIp(playerid,ipaddress,sizeof(ipaddress)); MySQLAddLoginRecord(PlayerInfo[playerid][pSQLID], ipaddress); ClearChatbox(playerid, 8); format(string2, sizeof(string2), "Server: Welcome to the State of San Andreas, %s.",playernamesplit[0]); SendClientMessage(playerid, COLOR_WHITE, string2); SendClientMessage(playerid, COLOR_WHITE, " "); printf("%s has logged in.",playername2); if (PlayerInfo[playerid][pDonateRank] > 0) { SendClientMessage(playerid, COLOR_WHITE,"People of LS: Thank you for donating so we can live!"); } if (PlayerInfo[playerid][pAdmin] > 0) { format(string2, sizeof(string2), "SERVER: You are logged in as a Level %d Admin.",PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_WHITE,string2); } if (PlayerInfo[playerid][pLinked] == 0) { SendClientMessage(playerid, COLOR_LIGHTRED, "WARNING: Your character is not linked to a website account! Register on moderntopia.com or some features will be restricted!"); } // Reset the FirstSpawn variable SetTimerEx("UnsetFirstSpawn", 5000, false, "i", playerid); SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1); if(gTeam[playerid] == 0) { gTeam[playerid] = 3; } else { gTeam[playerid] = PlayerInfo[playerid][pTeam]; } gPlayerLogged[playerid] = 1; SpawnPlayer(playerid); format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~y~ %s", playername2); DateProp(playerid); GameTextForPlayer(playerid, tmp2, 5000, 1); //SendClientMessage(playerid, COLOR_YELLOW, motd); if(PlayerInfo[playerid][pFMember] < 255) { format(tmp2, sizeof(tmp2), "Family MOTD: %s.", FamilyInfo[PlayerInfo[playerid][pFMember]][FamilyMOTD]); SendClientMessage(playerid, COLOR_YELLOW, tmp2); } //} return 1; }
mysql_fetch_row_format(string[],const delimiter[] = "|")