#1

Код:
#pragma tabsize 0

/*=======.Includes.=======*/
#include <a_samp>
#include <a_zones>
#include <a_mysql>
#include <streamer>
#include <foreach>
#include <yom_buttons>
#include <sscanf2>
#include <audio>
#include <gc_cmd>
#include <gc_selection>
#include <gc_bar>

/*=======.Defines.=======*/
#define mysql_host "127.0.0.1"
#define mysql_user "root"
#define mysql_password "123456"
#define mysql_database "rlrp"

#define Regdialog   1
#define Logdialog   2

/*=======.Anti AMX.=======*/
AntiDeAMX()
{
	new a[][] =
	{
		"Unarmed (Fist)",
		"Brass K"
	};
	#pragma unused a
}

enum Info
{
	Username[23],
	Password[24],
	Money
};
new PlayerInfo[MAX_PLAYERS][Info];

public OnGameModeInit()
{
    AntiDeAMX();
    
	SetGameModeText("Beta");
	mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password);
	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[80],pName[24],string[164];
	GetPlayerName(playerid,pName,24);
	format(Query,sizeof(Query),"SELECT `Username` FROM `Accounts` WHERE `Username` = '%s' LIMIT 1;",pName);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
	{
		format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
		ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Lo g in",string,"Login","");
	}
	else
	{
		format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
		ShowPlayerDialog(playerid,Logdialog,DIALOG_STYLE_INPUT,"Re gister",string,"Register","");
	}
	mysql_free_result();
	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 OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		return 1;
	}
	return 0;
}

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[])
{
    if(dialogid == Regdialog)
	{
		if(strlen(inputtext) == 0)
		{
			ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
		}
		else
		{
			new EscapedText[60],Query[80],pName[24];
			GetPlayerName(playerid,pName,24);
			mysql_real_escape_string(inputtext, EscapedText);
			format(Query,sizeof(Query),"INSERT INTO `Accounts` (Username,Password,Money) VALUES ('%s','%s,'0')",pName(playerid),EscapedText);
			mysql_query(Query);
			SendClientMessage(playerid,green,"You have been successfully registered!");
			GivePlayerMoney(playerid,5000);
			SetPlayerScore(playerid,100);
		}
	}
	if(dialogid == Logdialog)
	{
		if(strlen(inputtext) == 0)
		{
			ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
		}
		else
		{
			LoginPlayer(playerid,inputtext);
		}
	}
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
stock LoginPlayer(playerid,const password[])
{
	new EscapedText[60],pName[24];
	GetPlayerName(playerid,pName,24);
	mysql_real_escape_string(password, EscapedText);
	format(Query,sizeof(Query),"SELECT * FROM `Accounts` WHERE `Username` = '%s' AND `Password` = '%s'",pName(playerid),EscapedText);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows() != 0)
	{
		SendClientMessage(playerid,green,"You have been logged in!");
		LoadStats(playerid);
	}
	else
	{
		SendClientMessage(playerid,red,"Wrong password!");
		Kick(playerid);
	}
	mysql_free_result();
	return 1;
}
stock LoadStats(playerid)
{
	new pName[24],Query[80];
	GetPlayerName(playerid,pName,24);
	format(Query, sizeof(Query), "SELECT * FROM `Accounts` WHERE `Username` = '%s' ", pName);
	mysql_query(Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	sscanf(Query, "e<p<|>s[24]s[23]i>", PlayerInfo[playerid]);
	mysql_free_result();
	GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
	return 1;
}
Код:
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(73) : error 035: argument type mismatch (argument 1)
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(74) : error 017: undefined symbol "mysql_store_result"
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(75) : error 017: undefined symbol "mysql_num_rows"
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(85) : error 017: undefined symbol "mysql_free_result"
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(266) : error 012: invalid function call, not a valid address
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(266) : warning 215: expression has no effect
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(266) : error 001: expected token: ";", but found ")"
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(266) : error 029: invalid expression, assumed zero
E:\GameModes\samp03z_svr_R4_win32\gamemodes\RLRP.pwn(266) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


8 Errors.
i got this mysql plugin https://sampforum.blast.hk/showthread.php?tid=56564
Reply
#2

Your script uses functions from before R7 . Since R7, you cannot use non-threaded queries anymore. You either need to convert your script to use threaded queries (use search and you'll find many tutorials about it), or you need to use a < R7 version of the MySQL plugin.

EDIT:

You NEED to hash (encrypt) your passwords! You are storing them in PLAIN TEXT which is a HUGE security risk. Please do this before doing ANYTHING ELSE.
Reply
#3

alright.
Reply


Forum Jump:


Users browsing this thread: