Szerző Téma: SQL hibák [Script]  (Megtekintve 1117 alkalommal)

SQL hibák [Script]
« Dátum: 2016. szeptember 17. - 14:35:32 »
0 Show voters
Sziasztok!
Találtam a hiv. fórumon egy nagyon alap módot, ami nem tartalmaz semmit egy MySQL regisztrációs rendszeren kívül.
Nekem pont egy ilyenre lenne szükségem. Keresgéltem a google -n, olvastam ezt és azt, de vadászkutya legyek ha tudom mi a gondja. Addig én is vágom, hogy mi az az \"undefined\" symbol. Kb addig. :\'D
Aki vágja a témát, tudna nekem segíteni?
Előre is köszönöm!
 
E:\\XY\\Grand Theft Auto\\XY\\pawno\\include\\zcmd.inc(96) : warning 217: loose indentation
E:\\XY\\Grand Theft Auto\\XY\\pawno\\include\\zcmd.inc(97) : warning 217: loose indentation
E:\\XY\\Grand Theft Auto\\XY\\pawno\\include\\zcmd.inc(98) : warning 217: loose indentation
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(84) : error 017: undefined symbol \"LOG_ALL\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(85) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(116) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(117) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(288) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(289) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(299) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(300) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(398) : error 017: undefined symbol \"cache_get_data\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(402) : error 017: undefined symbol \"cache_get_field_content_int\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(403) : error 017: undefined symbol \"cache_get_field_content\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(404) : error 017: undefined symbol \"cache_get_field_content\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(397) : warning 203: symbol is never used: \"fields\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(411) : error 017: undefined symbol \"cache_get_field_content_int\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(412) : error 017: undefined symbol \"cache_get_field_content_int\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(413) : error 017: undefined symbol \"cache_get_field_content_int\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(414) : error 017: undefined symbol \"cache_get_field_content_int\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(416) : error 017: undefined symbol \"cache_get_field_content\"
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(450) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(451) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(480) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(481) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(486) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(489) : warning 213: tag mismatch
E:\\XY\\Grand Theft Auto\\XY\\gamemodes\\mysql.pwn(490) : warning 213: tag mismatch
Pawn compiler 3.2.3664           Copyright (c) 1997-2006, ITB CompuPhase
 
10 Errors.

 
A kódom:



 
main() {}
// --------------------------------------------------------------
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS    (50)
#include <a_mysql>
#include <zcmd>
#include <sscanf2>
// --------------------------------------------------------------
#define MYSQL_HOSTNAME    \"localhost\"
#define MYSQL_USERNAME    \"root\"
#define MYSQL_PASSWORD    \"\"
#define MYSQL_DATABASE    \"samp\"
#define GetPlayerDatabaseId(%0)   g_PlayerData[%0][eId]
#define GetPlayerNameEx(%0)      g_PlayerData[%0][eUsername]
#define IsPlayerLogged(%0)      BitFlag_Get(g_PlayerFlags[%0], eLogged)
#define GetPlayerCash(%0)      g_PlayerData[%0][eMoney]
#define SendErrorMessage(%0,%1)  SendClientMessage(%0, 0xFF0000, \"Error: \"%1)
#define SendSyntaxMessage(%0,%1) SendClientMessage(%0, 0xFF0000, \"Syntax: \"%1)
#define BitFlag_Get(%0,%1)      ((%0) & (%1))
#define BitFlag_On(%0,%1)       ((%0) |= (%1))
#define BitFlag_Off(%0,%1)      ((%0) &= ~(%1))
#define BitFlag_Toggle(%0,%1)   ((%0) ^= (%1))
#define BODY_PART_CHEST    (3)
#define BODY_PART_CROTCH    (4)
#define BODY_PART_LEFT_ARM    (5)
#define BODY_PART_RIGHT_ARM (6)
#define BODY_PART_LEFT_LEG    (7)
#define BODY_PART_RIGHT_LEG (8)
#define BODY_PART_HEAD       (9)
#define SPECIAL_ACTION_PISSING (68)
// --------------------------------------------------------------
enum /* Dialog ID */ {
DIALOG_REGISTER,
DIALOG_LOGIN
}
enum e_PlayerData {
eId,
eUsername[MAX_PLAYER_NAME + 1],
ePassword[65],
eSalt[11],
eAdmin,
eMoney,
eBanReason[32]
};
enum e_PlayerFlags: (<<= 1) {
eLogged = 1,
eAdminDuty
};
// --------------------------------------------------------------
static
g_PlayerData[MAX_PLAYERS][e_PlayerData],
e_PlayerFlags: g_PlayerFlags[MAX_PLAYERS],
dbHandle;
// --------------------------------------------------------------
native IsValidVehicle(vehicleid);
native GetGravity();
// --------------------------------------------------------------
forward public OnAccountCheck(playerid);
forward public OnAccountRegister(playerid);
forward public OnAccountLoad(playerid);
forward public KickTimer(playerid);
// --------------------------------------------------------------
public OnGameModeInit()
{
if(MAX_PLAYERS != GetMaxPlayers()) {
printf(\"> MAX_PLAYERS isn\'t equal to server slot in server.cfg. Please, redefine MAX_PLAYERS with correct number.\");
return SendRconCommand(\"exit\");
}
printf(\"> Connecting to %s with username %s and password %s at %s...\", MYSQL_DATABASE, MYSQL_USERNAME, (!strcmp(MYSQL_PASSWORD, \"\") ? (\"null\") : MYSQL_PASSWORD), MYSQL_HOSTNAME);
mysql_log(LOG_ALL, LOG_TYPE_HTML);
dbHandle = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_DATABASE, MYSQL_PASSWORD);
printf((mysql_errno() != 0) ? (\"> Can\'t connect at %s.\") : (\"> Connected at %s.\"), MYSQL_HOSTNAME);
SetGameModeText(\"MySql Base 1.0\");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
for(new e_PlayerData: i; i < e_PlayerData; i++)
g_PlayerData[playerid] = 0;
TogglePlayerSpectating(playerid, true);
BitFlag_Off(g_PlayerFlags[playerid], eLogged);
new szQuery[128], szName[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, szName, sizeof szName);
mysql_format(dbHandle, szQuery, sizeof szQuery, \"SELECT Id, Password, Salt FROM users WHERE Username = \'%e\' LIMIT 1\", szName);
mysql_tquery(dbHandle, szQuery, \"OnAccountCheck\", \"i\", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid) {
case DIALOG_REGISTER: {
   if(!response) return 0;
   new szSalt[11];
   for(new i; i < 10; i++) szSalt = random(79) + 47;
   szSalt[10] = 0;
   SHA256_PassHash(inputtext, szSalt, g_PlayerData[playerid][ePassword], 65);
   new szQuery[256], szUsername[MAX_PLAYER_NAME + 1];
   GetPlayerName(playerid, szUsername, sizeof szUsername);
        mysql_format(dbHandle, szQuery, sizeof szQuery, \"INSERT INTO `users` (`Username`, `Password`, `Salt`) VALUES (\'%e\', \'%e\', \'%e\')\", szUsername, g_PlayerData[playerid][ePassword], szSalt);
   mysql_tquery(dbHandle, szQuery, \"OnAccountRegister\", \"i\", playerid);
}
case DIALOG_LOGIN: {
   if (!response) return Kick(playerid);
   new szHash[65];
   SHA256_PassHash(inputtext, g_PlayerData[playerid][eSalt], szHash, 64);
   if (!strcmp(szHash, g_PlayerData[playerid][ePassword])) {
      new szQuery[128], szUsername[MAX_PLAYER_NAME + 1];
      GetPlayerName(playerid, szUsername, sizeof szUsername);
      mysql_format(dbHandle, szQuery, sizeof szQuery, \"SELECT * FROM users WHERE Username = \'%e\' LIMIT 1\", GetPlayerNameEx(playerid));
      mysql_tquery(dbHandle, szQuery, \"OnAccountLoad\", \"i\", playerid);
   } else {
      SendClientMessage(playerid, -1, \"Wrong password!\");
      ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, \"Log In\", \"Insert your password to login\", \"Login\", \"Quit\");
   }
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
return 1;
}
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    return 1;
}
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
return 1;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
return 1;
}
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
return 1;
}
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
return 1;
}
public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
return 1;
}
public OnIncomingConnection(playerid, ip_address[], port)
{
return 1;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
return 1;
}
public OnTrailerUpdate(playerid, vehicleid)
{
return 1;
}
public OnVehicleSirenStateChange(playerid, vehicleid, newstate)
{
return 1;
}
public OnActorStreamIn(actorid, forplayerid)
{
return 1;
}
public OnActorStreamOut(actorid, forplayerid)
{
return 1;
}
// --------------------------------------------------------------
public OnAccountCheck(playerid) {
new rows, fields;
cache_get_data(rows, fields);
if (!rows) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, \"Register\", \"Insert a password to register.\", \"Register\", \"Quit\");
g_PlayerData[playerid][eId] = cache_get_field_content_int(0, \"Id\");
cache_get_field_content(0, \"Password\", g_PlayerData[playerid][ePassword], dbHandle, 65);
cache_get_field_content(0, \"Salt\", g_PlayerData[playerid][eSalt], dbHandle, 11);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, \"Log In\", \"Insert your password to login\", \"Login\", \"Quit\");
return 1;
}
public OnAccountLoad(playerid) {
BitFlag_On(g_PlayerFlags[playerid], eLogged);
GetPlayerName(playerid, g_PlayerData[playerid][eUsername], MAX_PLAYER_NAME + 1);
g_PlayerData[playerid][eAdmin] = cache_get_field_content_int(0, \"Admin\");
GivePlayerCash(playerid, cache_get_field_content_int(0, \"Money\"));
SetPlayerScore(playerid, cache_get_field_content_int(0, \"Score\"));
if(cache_get_field_content_int(0, \"Ban\")) {
new szString[70], szBanReason[33];
cache_get_field_content(0, \"BanReason\", szBanReason[32], dbHandle, 32);
format(szString, sizeof szString, \"Your account has been banned from the server! Reason: %s\", szBanReason);
SendClientMessage(playerid, -1, szString);
SetTimerEx(\"KickTimer\", 500, false, \"d\", playerid);
}
BitFlag_Off(g_PlayerFlags[playerid], eAdminDuty);
SendClientMessage(playerid, -1, \"Welcome back to SERVER NAME\");
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, 0, random(311), 102.456, -77.207, 1.4, 68.307, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
public OnAccountRegister(playerid) {
g_PlayerData[playerid][eId] = cache_insert_id();
GetPlayerName(playerid, g_PlayerData[playerid][eUsername], MAX_PLAYER_NAME + 1);
SendClientMessage(playerid, -1, \"Welcome to SERVER NAME\");
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, 0, random(311), 102.456, -77.207, 1.4, 68.307, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
public KickTimer(playerid) return Kick(playerid);
// --------------------------------------------------------------
GivePlayerCash(playerid, cash) {
g_PlayerData[playerid][eMoney] += cash;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, g_PlayerData[playerid][eMoney]);
new szQuery[128];
mysql_format(dbHandle, szQuery, sizeof szQuery, \"UPDATE users SET Money=\'%d\' WHERE Id=\'%d\'\", GetPlayerDatabaseId(playerid));
mysql_tquery(dbHandle, szQuery);
}
// --------------------------------------------------------------
CMD:adminduty(playerid, params[]) {
if(!g_PlayerData[playerid][eAdmin]) return SendErrorMessage(playerid, \"You aren\'t able to use this command.\");
new szString[50];
if(BitFlag_Get(g_PlayerFlags[playerid], eAdminDuty)) {
BitFlag_On(g_PlayerFlags[playerid], eAdminDuty);
format(szString, sizeof szString, \"Admin %s in now on duty!\", GetPlayerNameEx(playerid));
} else {
BitFlag_Off(g_PlayerFlags[playerid], eAdminDuty);
format(szString, sizeof szString, \"Admin %s in now off duty!\", GetPlayerNameEx(playerid));
}
SetPlayerColor(playerid, (BitFlag_Get(g_PlayerFlags[playerid], eAdminDuty) ? (0xFFFF00AA) : (-1)));
SendClientMessageToAll(-1, szString);
return 1;
}
CMD:ban(playerid, params[]) {
if(!g_PlayerData[playerid][eAdmin]) return SendErrorMessage(playerid, \"You aren\'t able to use this command.\");
new iTargetId, szReason[32];
if(sscanf(params, \"us[32]\", iTargetId, szReason)) return SendSyntaxMessage(playerid, \"/ban [playerid/playername]\");
new szQuery[114];
if(IsPlayerLogged(iTargetId)) {
new szString[70];
format(szString, sizeof szString, \"Your account has been banned! Reason: %s\", szReason);
SendClientMessage(iTargetId, -1, szString);
format(szString, sizeof szString, \"You\'ve banned %s\", GetPlayerNameEx(iTargetId));
SendClientMessage(playerid, -1, szString);
mysql_format(dbHandle, szQuery, sizeof szQuery, \"UPDATE users SET Ban=\'1\', BanReason=\'%e\' WHERE Username=\'%e\'\", iTargetId);
mysql_tquery(dbHandle, szQuery);
SetTimerEx(\"KickTimer\", 500, false, \"d\", playerid);
} else {
new Cache: _Result;
format(szQuery, sizeof szQuery, \"SELECT * FROM users WHERE Username = \'%e\'\", iTargetId);
_Result = mysql_query(dbHandle, szQuery);
if(!cache_num_rows()) return SendErrorMessage(playerid, \"Player doesn\'t exists!\");
cache_delete(_Result);
mysql_format(dbHandle, szQuery, sizeof szQuery, \"UPDATE users SET Ban=\'1\', BanReason=\'%e\' WHERE Username=\'%e\'\", iTargetId);
mysql_tquery(dbHandle, szQuery);
SendClientMessage(playerid, -1, \"Player successfully banned!\");
}
return 1;
}

Nem elérhető 1Mark6

  • 437
    • Profil megtekintése
SQL hibák [Script]
« Válasz #1 Dátum: 2016. szeptember 17. - 15:00:14 »
0 Show voters
A MySQL inc. régi szerintem, próbáld meg frissíteni.

SQL hibák [Script]
« Válasz #2 Dátum: 2016. szeptember 17. - 15:03:11 »
0 Show voters
MySQL R41 mellé lévő includeot használok.

Nem elérhető 1Mark6

  • 437
    • Profil megtekintése
SQL hibák [Script]
« Válasz #3 Dátum: 2016. szeptember 17. - 15:11:50 »
0 Show voters
R41-ben módosították, ott nem szerepel \"cache_get_field_content_int\" / etc.
Próbáld meg egy R39-5s verzióval, vagy nézd meg hogy az adott szkript milyen MySQL-t igényel.

SQL hibák [Script]
« Válasz #4 Dátum: 2016. szeptember 17. - 15:39:01 »
0 Show voters
Mi alapján tudom eldönteni, hogy milyet igényel?
Elnézést, nem sok dolgom volt még SQL -el.
Bejött amit írtál, köszönöm a segítséged!
« Utoljára szerkesztve: 2016. szeptember 17. - 15:41:59 írta PabloEmilio »

Nem elérhető Flash

  • 5726
  • (っ◕‿◕)っ
    • Profil megtekintése
SQL hibák [Script]
« Válasz #5 Dátum: 2016. szeptember 17. - 22:28:18 »
0 Show voters
[gmod]Erre van kiemelt téma. zárok![/gmod]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal