15.06.2015, 13:01
Awesome work!
C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(34 : error 017: undefined symbol "posX"
C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(34 : warning 213: tag mismatch C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(349) : error 017: undefined symbol "posY" C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(349) : warning 213: tag mismatch C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(350) : error 017: undefined symbol "posZ" C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(350) : warning 213: tag mismatch C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(351) : error 017: undefined symbol "posA" C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(351) : warning 213: tag mismatch C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(353) : error 017: undefined symbol "SetPlayerMoney" C:\Users\Jaden\Desktop\SAMP Scripting\gamemodes\lsgw.pwn(355) : warning 217: loose indentation Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase |
public OnPlayerConnect(playerid) { printf("OnPlayerConnect begin"); new query[128]; PreparePlayerConnection(playerid); mysql_format(mysql, query, sizeof(query), "SELECT `pPassword`, `pID` FROM `accs` WHERE `pName` = '%e' LIMIT 1", PlayerName(playerid)); mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid); printf("OnPlayerConnect end"); return 1; } forward OnAccountCheck(playerid); public OnAccountCheck(playerid) { printf("OnAccountCheck begin"); new rows, fields, welcomestr[200]; cache_get_data(rows, fields, mysql); printf("OnAccountCheck get data"); if(rows) { printf("OnAccountCheck if rows begin"); cache_get_field_content(0, "Password", pData[playerid][pPass], mysql, 129); pData[playerid][pID] = cache_get_field_content_int(0, "pID"); format(welcomestr, sizeof(welcomestr), "Welcome %s!\nYour account has been previously registered in our database.\nPlease fill in your password:", GetPlayerForename(playerid)); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login to MY_TEST_SERVER.", welcomestr, "Login", "Quit"); printf("OnAccountCheck if rows end"); } else { printf("OnAccountCheck else begin"); format(welcomestr, sizeof(welcomestr), "Welcome to MY_TEST_SERVER, %s!\nIt appears that this is your first time playing here!\nPlease fill in your password below\nto register to MY_TEST_SERVER!", GetPlayerForename(playerid)); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register to MY_TEST_SERVER.", welcomestr, "Register", "Quit"); printf("OnAccountCheck else end"); } printf("OnAccountCheck end"); return 1; }
OnPlayerConnect begin OnPlayerConnect end
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, this, this, this, this)", playername, Player[playerid][Password], playerip);
Hello,
When I register on the server, I appear on Blueberry Farm. I edited this: Code:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, this, this, this, this)", playername, Player[playerid][Password], playerip); |
#define SPAWN_X 1.0
#define SPAWN_Y 2.0
#define SPAWN_Z 13.0 // usually the ground level in GTA SA
#define SPAWN_A 90.0 // Facing angle
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
[14:09:49] [ERROR] mysql_format - invalid connection handle (id: 0) [14:09:49] [ERROR] mysql_tquery - invalid connection handle (id: 0) [14:10:01] [ERROR] mysql_format - invalid connection handle (id: 0) [14:10:01] [ERROR] mysql_tquery - invalid connection handle (id: 0) |
public OnPlayerConnect(playerid)
{
new query[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
TogglePlayerSpectating(playerid, 1);
mysql_format(mysql, query, sizeof query, "SELECT 'Password', 'ID' FROM 'accounts' WHERE 'Name' = '%e' LIMIT 1", pName);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
SendClientMessage(playerid, COLOR_GREEN, "Awoo welcome back homie!");
return 1;
}
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "Password", PlayerInfo[playerid][pPassword], mysql, 129);
PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Welcome Enter your password to login", "Test Server", "Login", "Cancel");
}
else
{
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Welcome Create a password to register", "Test Server","Register", "Cancel");
}
return 1;
}
Till this point, we haven't really connected to the database yet. The connection happens in OnGameModeInit. Why? Because we would like to load all the data (not player-related) when the gamemode initializes. We use the following snippet of code to do so:
PHP Code:
|
It is the same. I'll show in detail what I mean:
Name -> '%e' -> playername Password -> '%e' -> Player[playerid][Password] IP -> '%e' -> playerip Admin -> 0 VIP -> 0 Money -> 0 Until this part, everything is correct but take a closer look to the rest: ?? -> %f -> ?? ?? -> %f -> ?? ?? -> %f -> ?? ?? -> %f -> ?? You have 4 specifiers that do not have columns nor arguments. |
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`) VALUES ('%e', '%e', '%e', 0, 0, 0)", playername, Player[playerid][Password], playerip);
OnAccountRegister
OnAccountCheck
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
PHP Code:
Edit: shouldnt PHP Code:
PHP Code:
PHP Code:
|