- 0
problema script
-
Similar Content
-
Recently Browsing 0 members
- No registered users viewing this page.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.
Question
sELevE
Incerc sa fac un sistem de register pe mysql si am dat de niste erori.
C:\Documents and Settings\Administrator\Desktop\samp037_svr_R2-1-1_win32\gamemodes\grandlarc.pwn(54) : error 017: undefined symbol "UserStats"
C:\Documents and Settings\Administrator\Desktop\samp037_svr_R2-1-1_win32\gamemodes\grandlarc.pwn(55) : error 017: undefined symbol "UserStats"
C:\Documents and Settings\Administrator\Desktop\samp037_svr_R2-1-1_win32\gamemodes\grandlarc.pwn(55) : error 017: undefined symbol "AccountExists"
C:\Documents and Settings\Administrator\Desktop\samp037_svr_R2-1-1_win32\gamemodes\grandlarc.pwn(56) : error 017: undefined symbol "AccountExists"
Stiu ca trebuie sa definesc alea, dar nu-mi dau seama cum. #define Userstats (...), #define AccountExist (...)
//----------------------------------------------------------
#include <a_samp>
#include <core>
#include <float>
#include "../include/gl_common.inc"
#include "../include/gl_spawns.inc"
#include "../include/a_mysql.inc"
#pragma tabsize 0
//----------------------------------------------------------
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_NORMAL_PLAYER 0xFFFFFFFF
#define mysql_host "localhost"
#define mysql_db "bazadate"
#define mysql_user "root"
#define mysql_pass ""
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
main()
{
print("\n---------------------------------------");
print("Starting TEST SERVER\n");
print("---------------------------------------\n");
}
//----------------------------------------------------------
CheckAccountExists(account[])
{
new string[128];
format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s'", account);
mysql_query(string);
mysql_store_result();
new value;
value = mysql_num_rows();
mysql_free_result();
return value;
}
public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid,"~w~TEST SERVER",3000,4);
SendClientMessage(playerid,COLOR_WHITE,"Welcome to {88AA88}T{FFFFFF}EST {88AA88}S{FFFFFF}erver");
GetPlayerName(playerid, UserStats[playerid][Name], MAX_PLAYER_NAME);
if(CheckAccountExists(UserStats[playerid][Name])) AccountExists[playerid] = 1;
else AccountExists[playerid] = 0;
return 1;
}
enum pEnum
{
Name[MAX_PLAYER_NAME],
Password[32],
Admin,
Money,
};
new UserStats[MAX_PLAYERS][pEnum];
new AccountExists[MAX_PLAYERS];
new PlayerLogged[MAX_PLAYERS];
ConnectMySQL()
{
if(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS))
print("[MySQL] Connection to the MySQL Database was successfully!");
else
print("[MySQL] Could not connect to the MySQL Database!");
}
CheckMySQL()
{
if(mysql_ping() == -1)
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
}
explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])
{
new
iNode,
iPointer,
iPrevious = -1,
iDelimiter = strlen(sDelimiter);
while(iNode < iVertices)
{
iPointer = strfind(sSource, sDelimiter, false, iPointer);
if(iPointer == -1)
{
strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
break;
}
else
{
strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
}
iPrevious = (iPointer += iDelimiter);
++iNode;
}
return iPrevious;
}
RegisterPlayer(playerid, password[])
{
if(AccountExists[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already registered!");
if(PlayerLogged[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");
if(strlen(password) < 3 || strlen(password) >= 32)
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");
CheckMySQL();
new string[128];
format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", UserStats[playerid][Name], password);
mysql_query(string);
AccountExists[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "[ACCOUNT] Your account has been created, please login now!");
LoginPlayer(playerid, password);
return 1;
}
LoginPlayer(playerid, password[])
{
if(!AccountExists[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're not registered!");
if(PlayerLogged[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");
if(strlen(password) < 3 || strlen(password) >= 32)
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");
CheckMySQL();
new string[128];
format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", UserStats[playerid][Name], password);
mysql_query(string);
mysql_store_result();
if(!mysql_num_rows())
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Incorrect password!");
new row[128];
new field[4][32];
mysql_fetch_row_format(row, "|");
explode(row, field, "|");
mysql_free_result();
format(UserStats[playerid][Password], 32, "%s", field[1]);
UserStats[playerid][Admin] = strval(field[2]);
UserStats[playerid][Money] = strval(field[3]);
GivePlayerMoney(playerid, UserStats[playerid][Money]);
format(string, sizeof(string), "[ACCOUNT] Welcome back %s, you are now logged in!", UserStats[playerid][Name]);
SendClientMessage(playerid, COLOR_YELLOW, string);
PlayerLogged[playerid] = 1;
return 1;
}
SavePlayer(playerid)
{
if(!PlayerLogged[playerid])
return 0;
UserStats[playerid][Money] = GetPlayerMoney(playerid);
CheckMySQL();
new string[256];
format(string, sizeof(string), "UPDATE Users SET Password='%s',Admin='%d',Money='%d' WHERE Name='%s'", UserStats[playerid][Password], UserStats[playerid][Admin], UserStats[playerid][Money], UserStats[playerid][Name]);
mysql_query(string);
return 1;
}
//----------------------------------------------------------
public OnPlayerSpawn(playerid)
{
SetPlayerPos(playerid, 1952.8693,1342.9752,15.3672);
SetPlayerCameraPos(playerid, 1952.8693,1342.9752,15.3672);
SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,200);
return 1;
}
//---------------------------------------------------------
2 answers to this question
Recommended Posts