27.06.2014, 20:30
Hey there, sa-mp community!
Here's the deal. I've took a long ass break from SA-MP scripting in general, must have been around 6 months or so. Therefore, I am rusty on my knowledge, so I came here for answers.
Basically, I've scripted this little login and registration system with MySQL R39. The compiler is showing no errors, therefore I assumed the gamemode was going to work. Then, I booted the server up, connected to it and it's just coming up the standard screens. No dialogs or anything.
Here's the code to the entire gamemode, as there is nothing I don't want people to know about:
Any sort of help will be appreciated with a reputation
Here's the deal. I've took a long ass break from SA-MP scripting in general, must have been around 6 months or so. Therefore, I am rusty on my knowledge, so I came here for answers.
Basically, I've scripted this little login and registration system with MySQL R39. The compiler is showing no errors, therefore I assumed the gamemode was going to work. Then, I booted the server up, connected to it and it's just coming up the standard screens. No dialogs or anything.
Here's the code to the entire gamemode, as there is nothing I don't want people to know about:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_commands>
#include <sscanf2>
#include <a_mysql>
// Gamemode Definitions
#define session_SVRNAME "ROLEPLAY"
#define session_SVRVER "DEV"
#define session_DEVBUILD "0.1"
#define session_CREATOR "Mitchell"
#define session_HOST "null"
#define Function::%1(%2) forward %1(%2); \
public %1(%2)
// Color Definitions
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA
#define COLOR_SEAGREEN2 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA
#define COLOR_YELLOWGREEN 0x9ACD32AA
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA
// Other Definitions
#define DIALOG_LOGIN 1
#define DIALOG_REGISTER 2
#define DIALOG_REGISTER_ERROR_1 3
#define sqlsession_HOST "localhost"
#define sqlsession_USER "root"
#define sqlsession_DB "rpsvr1"
#define sqlsession_PASS "countylife"
main()
{
print("\n\n\nSERVER: Gamemode Initialized\n\n\n");
}
new SQL;
public OnGameModeInit()
{
SQL = mysql_connect(sqlsession_HOST, sqlsession_USER, sqlsession_DB, sqlsession_PASS);
if(mysql_errno() == 2003)
{
print("[OnGameModeInit] Connection with the MySQL server could not be established. [ERR 2003]");
SendRconCommand("exit");
}
print("[OnGameModeInit] Connection with the MySQL server was successfully established.");
SetGameModeText(""session_SVRNAME": Version "session_SVRVER"");
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;
}
enum E_PLAYERDATA
{
ORM:ORM_ID,
ID,
Name[MAX_PLAYER_NAME+1],
Money,
Level,
Float:PosX,
Float:PosY,
Float:PosZ
};
new Player[MAX_PLAYERS][E_PLAYERDATA];
public OnPlayerConnect(playerid)
{
new pQuery[128];
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
mysql_format(SQL, pQuery, sizeof(pQuery), "SELECT * FROM `players` WHERE `Master` = '%e'", Player[playerid][Name]);
mysql_tquery(SQL, pQuery, "OnPlayerMySQLFinish", "d", playerid);
return 1;
}
Function::OnPlayerMySQLFinish(playerid)
{
if(cache_num_rows() == 1)
{
new ORM:ormid = Player[playerid][ORM_ID] = orm_create("players");
orm_addvar_int(ormid, Player[playerid][ID], "ID");
orm_addvar_string(ormid, Player[playerid][Name], MAX_PLAYER_NAME+1, "Master");
orm_addvar_int(ormid, Player[playerid][Money], "Money");
orm_addvar_int(ormid, Player[playerid][Level], "Level");
orm_addvar_float(ormid, Player[playerid][PosX], "PosX");
orm_addvar_float(ormid, Player[playerid][PosY], "PosY");
orm_addvar_float(ormid, Player[playerid][PosZ], "PosZ");
orm_setkey(ormid, "Master");
orm_apply_cache(ormid, 0);
new dialogString[128];
format(dialogString, sizeof(dialogString), "Welcome back to the server, %s! In order to play on this server, you're going to need to enter your password.\n\nPsst: {FF0000}Your password is by all means{FFFFFF} not {FF0000}shared with anybody!{FFFFFF}", Player[playerid][Name]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to the server!", dialogString, "Continue", "Exit");
}
else if(!cache_num_rows())
{
new dialogString[128];
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to the server!", dialogString, "Continue", "Exit");
}
else
{
SendClientMessage(playerid, -1, "idk");
}
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)
{
// Do something here
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[])
{
switch(dialogid)
{
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Error", "You didn't type anything! Type your password.", "Continue", "Exit");
new pQuery[128];
mysql_format(SQL, pQuery, sizeof(pQuery), "SELECT FROM `players` (Password) VALUES('%s') WHERE `Master` = '%e'", inputtext, Player[playerid][Name]);
mysql_tquery(SQL, pQuery, "OnPlayerLogin", "d", playerid);
}
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Error", "Your password needs to be atleast 6 characters long. Please try again.", "Continue", "Exit");
}
/// end end end
}
return 1;
}
Function::OnPlayerLogin(playerid)
{
if(cache_num_rows() == 1)
{
}
else
{
SendClientMessage(playerid, COLOR_RED, "Didnt work");
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
Any sort of help will be appreciated with a reputation