03.11.2012, 23:31
how to solve this?
pawn Код:
/* j_Register system by Jarnu!
Don't be selfish and don't remove credits!
*/
#include <a_samp>
#include <zcmd>
#include <a_mysql>
#include <sscanf2>
//===============MySQL DB Connection information================================
#define MYSQL_HOST "mysql4.000webhost.com"
#define MYSQL_USER "a7941613_test"
#define MYSQL_PASS "test12345"
#define MYSQL_DB "a7941613_test"
//==============================================================================
#define MAX_ADMIN_LEVEL 7 //Can be editted!
//----------Dialog ID-----------------
#define L_DIALOG 554 //Login dialog id
#define R_DIALOG 555 //Register dialog id
//----------------------------------
//----Credits------
#define AUTHOR "Jarnu"
#define VERSION "0.01"
#define SCRIPT "MySQL Based j_register system"
//----------------
#pragma tabsize 0
//=========================Register system stocks, enums ,variables=============
//----Enumerators------
enum pData
{
pAdmin,
pHelper,
pKills,
pScores,
pMoney,
pLogged,
pDeaths
};
//-------Variable for Enumerator------
new PlayerInfo[MAX_PLAYERS][pData];
//==============================================================================
//----Colors--------
#define cred "{E10000}"
#define corange "{FF7E19}"
#define cyellow "{FF9E00}"
#define cblue "{0087FF}"
#define cwhite "{FFFFFF}"
#define cgreen "{00FF28}"
#define cgrey "{969696}"
//------------------------------------------------------------------------------
#define GREEN 0x15FF00AA
#define RED 0xFF0000FF
#define BLUE 0x375FFFFF
#define WHITE 0xFFFFFFFF
#define YELLOW 0xF2FF00AA
#define GREY 0xAAAAAAAA
//------------------------------------------------------------------------------
//-------Change me!!--------------------
#define SERVERNAME "Jarnu's Server" //Change this to change the server name for login dialog!
//--------Extra stocks----------------------------------------------------------
//==============================================================================
stock MySQL_BanCheck(playerid)
{
new query[200], admin[50], pname[50], IP[16], string1[100];
GetPlayerIp(playerid, IP, 16);
format(query, sizeof(query),"SELECT * FROM `bandata` WHERE(`player`='%s' OR `IP`='%s') AND `banned`=1 LIMIT 1", escpname(playerid), IP);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
while(mysql_fetch_row(query))
{
mysql_fetch_field_row(admin, "admin");
mysql_fetch_field_row(pname, "player");
mysql_fetch_field_row(string1, "reason");
}
new string[50], str[50], str1[100];
format(string, sizeof(string),"Admin: %s", admin);
format(str, sizeof(str),"Player: %s", pname);
format(str1, sizeof(str1),"Reason: %s", string1);
SendClientMessage(playerid, RED,"You are banned from this server!");
SendClientMessage(playerid, RED,"___________________");
SendClientMessage(playerid, RED, str);
SendClientMessage(playerid, RED, string);
SendClientMessage(playerid, RED, str1);
SendClientMessage(playerid, RED,"___________________");
SendClientMessage(playerid, RED, "If you think you this is a mistake please visit our website");
SendClientMessage(playerid, RED, "YOUR WEBSITE"); //Change ME!
Kick(playerid);
}
mysql_free_result();
return 1;
}
//===================Saving and login stocks====================================
stock MySQL_Login(playerid)
{
new query[300], pname[24], savingstring[20];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "scores"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "adminlevel"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
mysql_fetch_field_row(savingstring, "helperlevel"); PlayerInfo[playerid][pHelper] = strval(savingstring);
mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
}
mysql_free_result();
new string[400];
PlayerInfo[playerid][pLogged] = 1;
format(string, sizeof(string),""cwhite"Scores: "corange"%d\n\n"cwhite"Money: "cyellow"$%d\n\n"cwhite"Kills: "cred"%d\n\n"cwhite"Deaths: "cred"%d\n\n"cwhite"Level: "cblue"%d\n\n"cwhite"Helper: "corange"%d\n\n"cwhite"Welcome to "cred"%s", GetPlayerScore(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pHelper], SERVERNAME);
ShowPlayerDialog(playerid, 1111, DIALOG_STYLE_MSGBOX,""cgreen"Logged in", string,"Close","");
return 1;
}
stock MySQL_Save(playerid)
{
if(PlayerInfo[playerid][pLogged] == 1)
{
new query[200], scores = GetPlayerScore(playerid), money = GetPlayerMoney(playerid), level = PlayerInfo[playerid][pAdmin], helper = PlayerInfo[playerid][pHelper], kills = PlayerInfo[playerid][pKills], deaths = PlayerInfo[playerid][pDeaths];
format(query, sizeof(query),"UPDATE `playerdata` SET scores=%d, kills=%d ,deaths=%d ,money=%d ,adminlevel=%d ,helperlevel=%d WHERE user='%s'",scores, kills, deaths, money, level, helper, PlayerName(playerid));
mysql_query(query);
SendClientMessage(playerid, 0xAAAAAAAA,"--------------");
SendClientMessage(playerid, GREEN,"Stats saved");
SendClientMessage(playerid, 0xAAAAAAAA,"---------------");
}
return 1;
}
//==============================================================================
//-----------admin stocks-------------------------
stock MessageToAdmins(color, const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
stock MessageToHelpers(color, const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1 || PlayerInfo[i][pHelper] == 1)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
stock TargetCMDMessage(playerid, target, command[])
{
new name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME];
GetPlayerName(target, name, sizeof(name));
GetPlayerName(playerid, name1, sizeof(name1));
new string[128];
format(string, sizeof(string),"[ADM.CMD] Administrator %s[%i] has used %s on %s[%i]", name1, playerid, command, name, target);
return MessageToAdmins(BLUE, string);
}
stock CMDMessage(playerid, command[])
{
new name1[MAX_PLAYER_NAME];
GetPlayerName(playerid, name1, sizeof(name1));
new string[128];
format(string, sizeof(string),"[ADM.CMD] Administrator %s[%i] has used %s", name1, playerid, command);
return MessageToHelpers(BLUE, string);
}
stock escpname(playerid)
{
new escname[24], Pname[24];
GetPlayerName(playerid, Pname, 24);
mysql_real_escape_string(Pname, escname);
return escname;
}
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
//------------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n--------------------------------------");
printf("%s loaded by %s version %s", SCRIPT, AUTHOR, VERSION);
print("--------------------------------------\n");
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(40), IP VARCHAR(16), money INT(20), scores INT(30), adminlevel INT(10), helperlevel INT(10), kills INT(20), deaths INT(20))");
mysql_query("CREATE TABLE IF NOT EXISTS bandata(admin VARCHAR(20), player VARCHAR(20), reason VARCHAR(50), IP VARCHAR(16), banned INT(10))");
mysql_debug();
return 1;
}
public OnFilterScriptExit()
{
print("\n--------------------------------------");
printf("%s unloaded by %s version %s", SCRIPT, AUTHOR, VERSION);
print("--------------------------------------\n");
return 1;
}
public OnPlayerConnect(playerid)
{
//--------------------------------
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pScores] = 0;
PlayerInfo[playerid][pMoney] = 0;
PlayerInfo[playerid][pAdmin] = 0;
PlayerInfo[playerid][pHelper] = 0;
//--------------------------------
MySQL_BanCheck(playerid);
//--------------------------------
//--------Account registration----
new query[200];
format(query, sizeof(query),"SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", PlayerName(playerid));
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
ShowPlayerDialog(playerid, R_DIALOG, DIALOG_STYLE_PASSWORD,""cgreen"Register",""corange"Your account is "cred"not "corange"registered\n"cgreen"Please type your password to register","Register","Quit");
}
if(rows == 1)
{
ShowPlayerDialog(playerid, L_DIALOG, DIALOG_STYLE_PASSWORD,""cgreen"Login",""corange"Your account is already registered\n"cgreen"Please type your password to login","Login","Quit");
}
mysql_free_result();
//---------------------------------
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
MySQL_Save(playerid); //-----------------To Save--------------------------//
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pDeaths] ++;
PlayerInfo[killerid][pKills] ++;
MySQL_Save(playerid); //-----------------To Save--------------------------//
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
//-------REGISTER SYSTEM------------------
if(dialogid == R_DIALOG)
{
if(!response) return Kick(playerid);
if(!strlen(inputtext) || strlen(inputtext) > 100)
{
SendClientMessage(playerid, RED,"[ERROR]: Password lenght must be greater than 1 and lesser than 100 words!");
ShowPlayerDialog(playerid, R_DIALOG, DIALOG_STYLE_PASSWORD,""cgreen"Register",""corange"Your account is "cred"not "corange"registered\n"cgreen"Please type your password to register","Register","");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
{
new escapepass[100];
mysql_real_escape_string(inputtext, escapepass);
new query[200], IP[16];
GetPlayerIp(playerid, IP, 16);
format(query, sizeof(query),"INSERT INTO playerdata(user, password, IP, money, scores, adminlevel, helperlevel, kills, deaths) VALUES('%s', SHA1('%s'), '%s', 0, 0, 0, 0, 0, 0)", PlayerName(playerid), escapepass, IP);
mysql_query(query);
PlayerInfo[playerid][pLogged] = 1;
SendClientMessage(playerid, GREEN,"[ACCOUNT]: You have been successfully registered!");
SendClientMessage(playerid, -1,"Generating your password...");
new string[100];
format(string, sizeof(string),"Your password is: "cgreen"%s", inputtext);
SendClientMessage(playerid, RED, string);
}
}
if(dialogid == L_DIALOG)
{
if(!response) return Kick(playerid);
if(response)
{
new query[200], pname[24], escapepass[100];
GetPlayerName(playerid, pname, 24);
mysql_real_escape_string(inputtext, escapepass);
format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
mysql_query(query);
mysql_store_result();
new numrows = mysql_num_rows();
if(numrows == 1) MySQL_Login(playerid);
if(!numrows)
{
SendClientMessage(playerid, RED,"[ERROR]: Incorrect password!");
ShowPlayerDialog(playerid, L_DIALOG, DIALOG_STYLE_PASSWORD,""cgreen"Login",""corange"Your account is already registered\n"cgreen"Please type your password to login","Login","");
}
mysql_free_result();
}
}
return 1;
}
//------------------------------------------------------------------------------
CMD:jcmds(playerid, params[])
{
SendClientMessage(playerid, GREEN,"--------| Jarnu's register system commands |---------");
SendClientMessage(playerid, BLUE, "---/changepass --- /setscore -- /kick");
SendClientMessage(playerid, BLUE, "BAN RELATED: ---/ban --- /unban -- /sban --");
SendClientMessage(playerid, BLUE, "---/sethelper --- /unsethelper -- /setadmin --");
SendClientMessage(playerid, GREEN,"--------| Thank you |---------");
return 1;
}
//------------------------------------------------------------------------------
CMD:setscore(playerid, params[])
{
new player1, amount;
if(PlayerInfo[playerid][pAdmin] >= 4)
{
if(sscanf(params,"dd", player1, amount)) return SendClientMessage(playerid, RED,"USAGE: /setscore [playerid][amount]");
if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, RED,"[ERROR]: Player not connected!");
SetPlayerScore(player1, amount);
TargetCMDMessage(playerid, player1,"SETSCORE");
new str[100], str1[100];
format(str, sizeof(str),"Administrator %s has setted your score(s) to %d", PlayerName(playerid),amount);
format(str1, sizeof(str1),"You have setted %s's score(s) to %d", PlayerName(player1), amount);
SendClientMessage(player1, BLUE, str);
SendClientMessage(playerid, BLUE, str1);
}
else return SendClientMessage(playerid, RED,"[ERROR]: You need to be admin level 4 to use this command!");
return 1;
}
//------------------------------------------------------------------------------
CMD:changepass(playerid, params[])
{
new pass[30];
if(sscanf(params,"s[30]", pass)) return SendClientMessage(playerid, RED,"[USAGE]: /changepass [new password]");
new query[200];
format(query, sizeof(query),"UPDATE `playerdata` SET password=SHA1('%s') WHERE `user`='%s'", pass, escpname(playerid));
mysql_query(query);
mysql_free_result();
new str[120];
format(str, sizeof(str),"Your password has been successfully changed to "cred"%s", pass);
SendClientMessage(playerid, GREEN,str);
return 1;
}
//------------------------------------------------------------------------------
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] == 1)
{
new player1, reason[100], str[100];
if(sscanf(params,"ds[100]", player1, reason)) return SendClientMessage(playerid, RED,"[USAGE]: /kick [playerid] [reason]");
if(IsPlayerConnected(player1))
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
format(str, sizeof(str),"%s has been kicked by Admin %s [Reason: %s]", PlayerName(player1), PlayerName(playerid), reason);
SendClientMessageToAll(RED, str);
TargetCMDMessage(playerid, player1,"KICK");
Kick(player1);
}
else if(PlayerInfo[playerid][pHelper] == 1)
{
format(str, sizeof(str),"%s has been kicked by Helper %s [Reason: %s]", PlayerName(player1), PlayerName(playerid), reason);
SendClientMessageToAll(RED, str);
CMDMessage(playerid,"KICK");
Kick(player1);
}
}
else return SendClientMessage(playerid, RED,"[ERROR]: Player is not connected!");
}
else return SendClientMessage(playerid, RED,"[ERROR]: You are not high enough level to use this command!");
return 1;
}
//------------------------------------------------------------------------------
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
{
new targetid, reason[100];
if(sscanf(params,"ds[100]", targetid, reason)) return SendClientMessage(playerid, RED,"[USAGE]: /ban [playerid][reason]");
if(!IsPlayerConnected(playerid) && targetid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, RED,"[ERROR]: Player is not connected!");
}
if(PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin])
{
SendClientMessage(playerid, RED,"You have been kicked for trying to ban your senior!");
Kick(playerid);
}
else
{
new bquery[200], IP[16];
GetPlayerIp(targetid, IP, 16);
format(bquery, sizeof(bquery),"INSERT INTO bandata(admin, player, reason, IP, banned) VALUES('%s', '%s', '%s','%s', 1)", PlayerName(playerid),PlayerName(targetid), reason, IP);
mysql_query(bquery);
CMDMessage(playerid,"BAN");
new string[256];
format(string, sizeof(string),"%s has been banned by Admin %s [Reason: %s]", PlayerName(targetid), PlayerName(playerid), reason);
SendClientMessageToAll(RED, string);
mysql_free_result();
Kick(targetid);
}
} else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin or level 2 admin to use this command!");
return 1;
}
//------------------------------------------------------------------------------
CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
{
new target[50];
if(sscanf(params,"s[50]", target)) return SendClientMessage(playerid, RED,"[USAGE]: /unban [player name]");
new query[200];
format(query, sizeof(query),"SELECT * FROM `bandata` WHERE `player`='%s' AND `banned`=1 LIMIT 1", target);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(rows == 1)
{
new uquery[200];
format(uquery, sizeof(uquery),"DELETE FROM `bandata` WHERE player='%s'", target);
mysql_query(uquery);
mysql_store_result();
new string[200];
CMDMessage(playerid,"UNBAN");
format(string, sizeof(string),"You have unbanned %s", target);
SendClientMessage(playerid, BLUE,string);
}
else if(!rows)
{
new str[128];
format(str, sizeof(str),"[ERROR]: No ban found on this name %s", target);
SendClientMessage(playerid, RED, str);
mysql_free_result();
}
} else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin or level 2 admin to use this command!");
return 1;
}
//------------------------------------------------------------------------------
CMD:sban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
{
new target[50], admin[50], player[50], reason[100], IP[16];
if(sscanf(params,"s[50]", target)) return SendClientMessage(playerid, RED,"[USAGE]: /sban [player name]");
new query[200];
format(query, sizeof(query),"SELECT admin,player,reason,IP FROM `bandata` WHERE `player`='%s' AND `banned`=1 LIMIT 1", target);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(rows == 1)
{
while(mysql_fetch_row(query))
{
mysql_fetch_field_row(admin, "admin");
mysql_fetch_field_row(player, "player");
mysql_fetch_field_row(IP, "IP");
mysql_fetch_field_row(reason, "reason");
}
new string[128];
format(string, sizeof(string),"Admin: %s | Player:%s | Reason:%s | IP:%s " , admin, player, reason, IP);
SendClientMessage(playerid, RED, string);
}
if(!rows)
{
SendClientMessage(playerid, RED,"[ERROR]: No ban found on this name!");
}
}
else return SendClientMessage(playerid, RED,"[ERROR]: You are not high enough level to use this command!");
return 1;
}
//------------------------------------------------------------------------------
CMD:setadmin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5 || IsPlayerAdmin(playerid))
{
new string[125], level, player1;
if(sscanf(params,"dd",player1, level)) return SendClientMessage(playerid, RED,"[USAGE]: /setadmin ( playerid ) ( level )");
if(!IsPlayerConnected(playerid) && player1 != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, RED,"[ERROR]: Player is not connected");
}
if(level > MAX_ADMIN_LEVEL)
{
SendClientMessage(playerid, RED,"[ERROR]: Incorrect level");
}
else
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, sizeof(aname));
format(string, sizeof(string),""cblue"Administrator "cgreen"'%s' "cblue"has set your admin level to "cgreen"[Level %d]", aname,level);
SendClientMessage(player1, BLUE, string);
TargetCMDMessage(playerid, player1,"SETADMIN");
PlayerPlaySound(player1,1057,0.0,0.0,0.0);
PlayerInfo[player1][pAdmin] = level;
}
}
else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin or level 5 admin to use this command");
return 1;
}
//------------------------------------------------------------------------------
CMD:sethelper(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5 || IsPlayerAdmin(playerid))
{
new string[125], player1;
if(sscanf(params,"d",player1)) return SendClientMessage(playerid, RED,"[USAGE]: /sethelper ( playerid )");
if(!IsPlayerConnected(playerid) && player1 != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, RED,"[ERROR]: Player is not connected");
}
else
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, sizeof(aname));
format(string, sizeof(string),""cblue"Administrator "cgreen"'%s' "cblue"has set you to helper status", aname);
SendClientMessage(player1, BLUE, string);
TargetCMDMessage(playerid, player1,"SETHELPER");
PlayerPlaySound(player1,1057,0.0,0.0,0.0);
PlayerInfo[player1][pHelper] = 1;
}
}
else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin or level 5 admin to use this command");
return 1;
}
//------------------------------------------------------------------------------
CMD:unsethelper(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5 || IsPlayerAdmin(playerid))
{
new string[125], player1;
if(sscanf(params,"d",player1)) return SendClientMessage(playerid, RED,"[USAGE]: /unsethelper ( playerid )");
if(!IsPlayerConnected(playerid) && player1 != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, RED,"[ERROR]: Player is not connected");
}
else
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, sizeof(aname));
format(string, sizeof(string),""cblue"Administrator "cgreen"'%s' "cblue"has "cred"DEMOTED "cblue"you to player", aname);
SendClientMessage(player1, BLUE, string);
TargetCMDMessage(playerid, player1,"UNSETHELPER");
PlayerPlaySound(player1,1057,0.0,0.0,0.0);
PlayerInfo[player1][pHelper] = 0;
}
}
else return SendClientMessage(playerid, RED,"[ERROR]: You need to be RCON admin or level 5 admin to use this command");
return 1;
}
//=========Thank you============================================================
Код:
C:\Users\Julius\Desktop\Test\pawno\include\a_mysql.inc(70) : error 001: expected token: ";", but found "native" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.