[HELP] MySQL -
Povis - 11.07.2014
Hi, I have a problem. I know where is the problem, but I'm not good to fix it, because I don't know what i must write at the function.
Errors:
Код:
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(82) : error 017: undefined symbol "mysql_query"
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(193) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(200) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(200) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(215) : error 017: undefined symbol "mysql_query"
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(239) : error 017: undefined symbol "mysql_query"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
This is 82 line's error:
This is 215 line's error:
This is 239 line's error:
Some people said, that new version of MySQL doesn't have "mysql_query" function, it's different now, but please help me, I'm doing regiter/login system, and this is system's script:
Код:
#include <sscanf>
#include <a_mysql>
Код:
public OnGameModeInit()
{
mysql_connect("localhost", "root", "Estetra", "");
Код:
public OnPlayerConnect(playerid)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SECELT * FROM accounts WHERE name = '%s'", pName);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendClientMessage(playerid, -1, "That username is registered!");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
}
else
{
SendClientMessage(playerid, -1, "That username is not registered. You may register it");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Register", "Please enter a password you will remember", "Register", "Cancel");
}
return 1;
}
Код:
case 1:
{
if(response)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SELECT password FROM accounts WHERE name = '%s' AND password = '%s'", pName);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() ==1)
{
SendClientMessage(playerid, -1, "You Have successfully signed in!");
SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 1, 999, 1, 999, 1, 999);
SpawnPlayer(playerid);
}
else
{
SendClientMessage(playerid, -1, "Incorrect Password!");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
}
}
}
case 2:
{
if(response)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "INSERT INTO accounts VALUES ('%s', '%s')", pName, inputtext);
mysql_query(query);
SendClientMessage(playerid, -1, "You have registered!");
SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 1, 999, 1, 999, 1, 999);
}
}
}
return 1;
}
Re: [HELP] MySQL -
BroZeus - 11.07.2014
get the latest include of mysql and its plugin
Re: [HELP] MySQL -
Povis - 11.07.2014
I had old version and there was about 9 errors, but now I changed to R7 and now it's only 3 errors and only with "mysql_query". Please help.
Re : [HELP] MySQL -
S4t3K - 11.07.2014
The R7 needs a new parameter called "connection handle" (a first parameter) since BlueG has included a multi connections system in his plugin.
Simply create a global variable called (for example) sql.
Then, replace your mysql_connect line by this one :
pawn Код:
sql = mysql_connect("localhost", "root", "Estetra", "");
Finally, in all your queries, use this syntax :
Regards.
Re: [HELP] MySQL -
Povis - 11.07.2014
Thanks, now server is working, but my few systems doesn't work properly. When I join the server, I register and then I register at the exact same time other dialog shows up (vehicle spawner dialog) and I can' understand where is a problem, this is my all script if anyone is willing to help me:
Код:
/*******************************************************************************
* SERVER NAME: Gamemode
* SERVER VERSION: Mode v1.0
* SERVER DEVELOPER: Magahaka
*
* INFORMATION:
*
*******************************************************************************/
//----- Includes -----//
#include <a_samp>
#include <a_colors>
#include <zcmd>
#include <sscanf>
#include <a_mysql>
//----- Defines -----//
new SpawnedVehicle[MAX_PLAYERS];
new sql;
//----- Forwards -----//
forward LoadPlayer(playerid, name[], value[]);
//----- Enums -----//
enum
{
DIALOG_VEHICLE
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Alachu Akbar Is Here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
main()
{
print("SERVER: Fero Estetra");
print("VERSION: Mode v1.0");
print("DEVELOPER: Magahaka");
}
public OnGameModeInit()
{
sql = mysql_connect("localhost", "root", "Estetra", "");
SetGameModeText("Estetra v2.0.0");
//------------------------[PLAYER CLASS SELECTION]--------------------------
AddPlayerClass(288,257.3560,-77.7318,1.5781,0.9956,31,500,0,0,0,0);
//---------------------------[SERVER VEHICLES]------------------------------
AddStaticVehicle(541,265.1755,-66.7250,1.5781,90.2553,1,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)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SECELT * FROM accounts WHERE name = '%s'", pName);
mysql_function_query(sql, query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendClientMessage(playerid, -1, "That username is registered!");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
}
else
{
SendClientMessage(playerid, -1, "That username is not registered. You may register it");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Register", "Please enter a password you will remember", "Register", "Cancel");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(SpawnedVehicle[playerid]);
return 1;
}
//----- Generated Commands -----//
CMD:vehicle(playerid, params[]) //Vehicle Spawner
{
if(IsPlayerConnected(playerid))
{
if(SpawnedVehicle[playerid] == -1)
{
ShowPlayerDialog(playerid, DIALOG_VEHICLE, DIALOG_STYLE_INPUT, "Vehicle Spawner v2.0", " Бraрykite maрinos ID (400 - 611)", "Gauti", "Atрaukti");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "Jыs jau turite maрinа.");
return 1;
}
}
return 1;
}
CMD:destroy(playerid, params[]) //Vehicle Spawner Car Destroy Command
{
if(SpawnedVehicle[playerid] == -1) return SendClientMessage(playerid, COLOR_YELLOW, "Negalite sunaikinti maрinos kurios neturi.");
DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = -1;
SendClientMessage(playerid, COLOR_RED, "Sunaikinote savo maрinа.");
return 1;
}
//----- Generated Publics -----//
public LoadPlayer(playerid, name[], value[])
{
SpawnedVehicle[playerid] = -1;
return 1;
}
//----- Generated Dialogs -----//
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_VEHICLE:
{
new vnum:
vnum = strval(inputtext);
if(!response)
{
return 1;
}
else
{
if(vnum < 400 || vnum > 611) return ShowPlayerDialog(playerid, DIALOG_VEHICLE, DIALOG_STYLE_INPUT, "Vehicle Spawner v2.0", " Бraрykite maрinos ID (400 - 611)", "Gauti", "Atрaukti");
{
SpawnVehicleForPlayer(vnum, playerid);
SendClientMessage(playerid, COLOR_RED, "Katik gavote maрinа.");
}
}
}
case 1:
{
if(response)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SELECT password FROM accounts WHERE name = '%s' AND password = '%s'", pName);
mysql_function_query(sql, query);
mysql_store_result();
if(mysql_num_rows() ==1)
{
SendClientMessage(playerid, -1, "You Have successfully signed in!");
SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 1, 999, 1, 999, 1, 999);
SpawnPlayer(playerid);
}
else
{
SendClientMessage(playerid, -1, "Incorrect Password!");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
}
}
}
case 2:
{
if(response)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "INSERT INTO accounts VALUES ('%s', '%s')", pName, inputtext);
mysql_function_query(sql, query);
SendClientMessage(playerid, -1, "You have registered!");
SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 1, 999, 1, 999, 1, 999);
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
//----- Stocks -----//
stock SpawnVehicleForPlayer(vehicleid, playerid)
{
if(SpawnedVehicle[playerid] != -1)
{
DestroyVehicle(SpawnedVehicle[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Angle;
{
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
SpawnedVehicle[playerid] = CreateVehicle(vehicleid, X, Y, Z+2, Angle, -1, -1, -1);
SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, SpawnedVehicle[playerid], 0);
}
}
It's like this: 1) asking to register. 2) asking to enter a vehicle ids (but I didn't typed a command /vehicle for it, it happened automaticly somehow).