SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/03/2015, 11:59 PM   #1
DRP
Big Clucker
 
Join Date: Apr 2014
Posts: 133
Reputation: 46
Default Registration Problem Error

Hello there!
I've been scripting/making a new registration system for my server, and I got no error, but when I try registering in game, it's not working, the code will be below, I will be awaiting a reply

Code:
#include <a_samp>
#include <a_mysql>
#include <sscanf2>
#include <zcmd>
#include <foreach>


#define SQL_HOSTNAME "127.0.0.1"
#define SQL_USERNAME "root"
#define SQL_DATABASE "luxery"
#define SQL_PASSWORD ""

#define dregister    6287 
#define dlogin        6288

#define SERVER_NAME "[0.3z] .::Luxury Roleplay::."
#define SERVER_URL ""
#define SERVER_MAP "Los Santos"
#define SERVER_REVISION ("v0.02")
#define SERVER_CITY 	(1)

#define ADMINBLUE 		  (0x1D7CF2FF)
#define SERVERCOLOR		  (0xA9C4E4FF)
#define COLOR_CLIENT      (0xAAC4E5FF)
#define COLOR_WHITE       (0xFFFFFFFF)
#define COLOR_RED         (0xFF0000FF)
#define COLOR_CYAN        (0x33CCFFFF)
#define COLOR_LIGHTRED    (0xFF6347FF)
#define COLOR_LIGHTGREEN  (0x9ACD32FF)
#define COLOR_YELLOW      (0xFFFF00FF)
#define COLOR_GREY        (0xAFAFAFFF)
#define COLOR_HOSPITAL    (0xFF8282FF)
#define COLOR_PURPLE      (0xD0AEEBFF)
#define COLOR_LIGHTYELLOW (0xF5DEB3FF)
#define COLOR_DARKBLUE    (0x1394BFFF)
#define COLOR_ORANGE      (0xFFA500FF)
#define COLOR_LIME        (0x00FF00FF)
#define COLOR_GREEN       (0x33CC33FF)
#define COLOR_BLUE        (0x2641FEFF)
#define COLOR_FACTION     (0xBDF38BFF)
#define COLOR_RADIO       (0x8D8DFFFF)
#define COLOR_LIGHTBLUE   (0x007FFFFF)
#define COLOR_SERVER      (0xFFFF90FF) // 6688FF
#define COLOR_DEPARTMENT  (0xF0CC00FF)
#define COLOR_PINK 		  (0xFF66FF00)
#define COLOR_ADMINCHAT   (0x33EE33FF)
#define DEFAULT_COLOR     (0xFFFFFFFF)

native WP_Hash(buffer[], len, const str[]); 

static
	mysql, 
	Name[MAX_PLAYERS][24], 
	IP[MAX_PLAYERS][16] 
	;
	
enum PlayerInfo 
{
	CMD1[129],
    CMD2[129],
    CMD3[129],
    CMD4[129],
    CMD5[129],
	ID, 
	Password[129], 
	Skin,
	Admin,
	Moderator,
	Helper,
	Gold,
	Money, 
	Float:posX, 
	Float:posY, 
	Float:posZ,
	pSpectator,
	pInterior,
	pWorld
}
new pInfo[MAX_PLAYERS][PlayerInfo]; 
new g_iHandle;

new Text:Stats1[MAX_PLAYERS];
new Text:SpecLastCMD;
new Text:SpecCMDBG;
new Text:SpecCmd1[MAX_PLAYERS];
new Text:SpecCmd2[MAX_PLAYERS];
new Text:SpecCmd3[MAX_PLAYERS];
new Text:SpecCmd4[MAX_PLAYERS];
new Text:SpecCmd5[MAX_PLAYERS];

new ahide[MAX_PLAYERS];
new abusy[MAX_PLAYERS];

//stocks

main() {
	print("Luxury Roleplay");
}

SQL_Connect() {
	g_iHandle = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD);

	if (g_iHandle < 1) {
	    printf("[SQL] Connection to \"%s\" failed! Please check the connection settings...\a", SQL_HOSTNAME);
	}
	else {
		printf("[SQL] Connection to \"%s\" passed!", SQL_HOSTNAME);
	}
}

stock SendClientMessageEx(playerid, color, const str[], {Float,_}:...)
{
	static
	    args,
	    start,
	    end,
	    string[144]
	;
	#emit LOAD.S.pri 8
	#emit STOR.pri args

	if (args > 12)
	{
		#emit ADDR.pri str
		#emit STOR.pri start

	    for (end = start + (args - 12); end > start; end -= 4)
		{
	        #emit LREF.pri end
	        #emit PUSH.pri
		}
		#emit PUSH.S str
		#emit PUSH.C 144
		#emit PUSH.C string
		#emit PUSH.C args
		#emit SYSREQ.C format

		SendClientMessage(playerid, color, string);

		#emit LCTRL 5
		#emit SCTRL 4
		#emit RETN
	}
	return SendClientMessage(playerid, color, str);
}

stock BanPlayer(playerid) {
	new query[128], player_ip[16], bool:banned = false;
	GetPlayerIp(playerid, player_ip, sizeof(player_ip));
    format(query, sizeof(query), "SELECT * FROM `bans` WHERE `Reason`, `Bannedby`, `ip` = '%s' , '%s', '%s'",banreason, Lname(playerid),player_ip);
	mysql_query(query);
	mysql_store_result();
	banned = mysql_num_rows>0;
	mysql_free_result();
	return banned;
}

stock UnbanPlayer(ip[]) {
	new query[128];
	format(query, sizeof(query), "DELETE FROM `bans` WHERE `Reason`, `Bannedby`, `ip` = '%s' , '%s', '%s'",banreason, Lname(playerid),player_ip);
	mysql_query(query);
}

stock SendNearbyMessage(playerid, Float:radius, color, const str[], {Float,_}:...)
{
	static
	    args,
	    start,
	    end,
	    string[144]
	;
	#emit LOAD.S.pri 8
	#emit STOR.pri args

	if (args > 16)
	{
		#emit ADDR.pri str
		#emit STOR.pri start

	    for (end = start + (args - 16); end > start; end -= 4)
		{
	        #emit LREF.pri end
	        #emit PUSH.pri
		}
		#emit PUSH.S str
		#emit PUSH.C 144
		#emit PUSH.C string

		#emit LOAD.S.pri 8
		#emit CONST.alt 4
		#emit SUB
		#emit PUSH.pri

		#emit SYSREQ.C format
		#emit LCTRL 5
		#emit SCTRL 4

        foreach (new i : Player)
		{
			if (IsPlayerNearPlayer(i, playerid, radius)) {
  				SendClientMessage(i, color, string);
			}
		}
		return 1;
	}
	foreach (new i : Player)
	{
		if (IsPlayerNearPlayer(i, playerid, radius)) {
			SendClientMessage(i, color, str);
		}
	}
	return 1;
}

stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
{
	static
		Float:fX,
		Float:fY,
		Float:fZ;

	GetPlayerPos(targetid, fX, fY, fZ);

	return (GetPlayerInterior(playerid) == GetPlayerInterior(targetid) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid)) && IsPlayerInRangeOfPoint(playerid, radius, fX, fY, fZ);
}

stock Lname(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}

stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
        {
            SendClientMessage(i,color,string);
            }
    }
}
//forward
forward OnPlayerConnect(playerid);
forward OnAccountLoad(playerid);
forward OnAccountRegister(playerid);
//public

public OnPlayerConnect(playerid)
{
	ahide[playerid] = 0;
	abusy[playerid] = 0;
	new query[128]; 
	GetPlayerName(playerid, Name[playerid], 24); 
	GetPlayerIp(playerid, IP[playerid], 16);
	mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
	mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
	
	Stats1[playerid] = TextDrawCreate(0.000000, 437.000000, "Name:");
	TextDrawBackgroundColor(Stats1[playerid], 255);
	TextDrawFont(Stats1[playerid], 1);
	TextDrawLetterSize(Stats1[playerid], 0.250000, 1.000000);
	TextDrawColor(Stats1[playerid], -16776961);
	TextDrawSetOutline(Stats1[playerid], 1);
	TextDrawSetProportional(Stats1[playerid], 1);
	TextDrawUseBox(Stats1[playerid], 1);
	TextDrawBoxColor(Stats1[playerid], 255);
	TextDrawTextSize(Stats1[playerid], 640.000000, 0.000000);

	SpecCmd1[playerid] = TextDrawCreate(445.000000, 146.000000, "_");
	TextDrawBackgroundColor(SpecCmd1[playerid], 255);
	TextDrawFont(SpecCmd1[playerid], 1);
	TextDrawLetterSize(SpecCmd1[playerid], 0.330000, 0.799999);
	TextDrawColor(SpecCmd1[playerid], -1);
	TextDrawSetOutline(SpecCmd1[playerid], 0);
	TextDrawSetProportional(SpecCmd1[playerid], 1);
	TextDrawSetShadow(SpecCmd1[playerid], 1);
	TextDrawUseBox(SpecCmd1[playerid], 1);
	TextDrawBoxColor(SpecCmd1[playerid], 17);
	TextDrawTextSize(SpecCmd1[playerid], 632.000000, 0.000000);

	SpecCmd2[playerid] = TextDrawCreate(445.000000, 183.000000, "_");
	TextDrawBackgroundColor(SpecCmd2[playerid], 255);
	TextDrawFont(SpecCmd2[playerid], 1);
	TextDrawLetterSize(SpecCmd2[playerid], 0.330000, 0.799999);
	TextDrawColor(SpecCmd2[playerid], -1);
	TextDrawSetOutline(SpecCmd2[playerid], 0);
	TextDrawSetProportional(SpecCmd2[playerid], 1);
	TextDrawSetShadow(SpecCmd2[playerid], 1);
	TextDrawUseBox(SpecCmd2[playerid], 1);
	TextDrawBoxColor(SpecCmd2[playerid], 17);
	TextDrawTextSize(SpecCmd2[playerid], 632.000000, 0.000000);

	SpecCmd3[playerid] = TextDrawCreate(445.000000, 219.000000, "_");
	TextDrawBackgroundColor(SpecCmd3[playerid], 255);
	TextDrawFont(SpecCmd3[playerid], 1);
	TextDrawLetterSize(SpecCmd3[playerid], 0.330000, 0.799999);
	TextDrawColor(SpecCmd3[playerid], -1);
	TextDrawSetOutline(SpecCmd3[playerid], 0);
	TextDrawSetProportional(SpecCmd3[playerid], 1);
	TextDrawSetShadow(SpecCmd3[playerid], 1);
	TextDrawUseBox(SpecCmd3[playerid], 1);
	TextDrawBoxColor(SpecCmd3[playerid], 17);
	TextDrawTextSize(SpecCmd3[playerid], 632.000000, 0.000000);

	SpecCmd4[playerid] = TextDrawCreate(445.000000, 255.000000, "_");
	TextDrawBackgroundColor(SpecCmd4[playerid], 255);
	TextDrawFont(SpecCmd4[playerid], 1);
	TextDrawLetterSize(SpecCmd4[playerid], 0.330000, 0.799999);
	TextDrawColor(SpecCmd4[playerid], -1);
	TextDrawSetOutline(SpecCmd4[playerid], 0);
	TextDrawSetProportional(SpecCmd4[playerid], 1);
	TextDrawSetShadow(SpecCmd4[playerid], 1);
	TextDrawUseBox(SpecCmd4[playerid], 1);
	TextDrawBoxColor(SpecCmd4[playerid], 17);
	TextDrawTextSize(SpecCmd4[playerid], 632.000000, 0.000000);

	SpecCmd5[playerid] = TextDrawCreate(445.000000, 291.000000, "_");
	TextDrawBackgroundColor(SpecCmd5[playerid], 255);
	TextDrawFont(SpecCmd5[playerid], 1);
	TextDrawLetterSize(SpecCmd5[playerid], 0.330000, 0.799999);
	TextDrawColor(SpecCmd5[playerid], -1);
	TextDrawSetOutline(SpecCmd5[playerid], 0);
	TextDrawSetProportional(SpecCmd5[playerid], 1);
	TextDrawSetShadow(SpecCmd5[playerid], 1);
	TextDrawUseBox(SpecCmd5[playerid], 1);
	TextDrawBoxColor(SpecCmd5[playerid], 17);
	TextDrawTextSize(SpecCmd5[playerid], 632.000000, 0.000000);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new query[128], Float:pos[3];
	GetPlayerPos(playerid, pos[0], pos[1], pos[2]); 
	mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Gold`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f WHERE `ID`=%d",\
	pInfo[playerid][Admin], pInfo[playerid][Gold], pInfo[playerid][Money], pos[0], pos[1], pos[2], pInfo[playerid][ID]);
	mysql_tquery(mysql, query, "", "");

	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This command is unknown, use /help for a list of commands.");  //If the command was wrong/invalid
    if(success)
    {
        format(pInfo[playerid][CMD1], 129, "%s", pInfo[playerid][CMD2]);
        format(pInfo[playerid][CMD2], 129, "%s", pInfo[playerid][CMD3]);
        format(pInfo[playerid][CMD3], 129, "%s", pInfo[playerid][CMD4]);
        format(pInfo[playerid][CMD4], 129, "%s", pInfo[playerid][CMD5]);
        format(pInfo[playerid][CMD5], 129, "%s", cmdtext);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posZ], pInfo[playerid][posZ]);
    return 1;
}

public OnAccountLoad(playerid)
{
 	pInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
	pInfo[playerid][Moderator] = cache_get_field_content_int(0, "Moderator");
 	pInfo[playerid][Helper] = cache_get_field_content_int(0, "Helper");
 	pInfo[playerid][Gold] = cache_get_field_content_int(0, "Gold");
 	pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
 	pInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin");
 	pInfo[playerid][posX] = cache_get_field_content_float(0, "PosX");
 	pInfo[playerid][posY] = cache_get_field_content_float(0, "PosY");
 	pInfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");

 	GivePlayerMoney(playerid, pInfo[playerid][Money]);
	SendClientMessage(playerid, -1, "Successfully logged in"); 
	return 1;
}

public OnAccountRegister(playerid)
{
    pInfo[playerid][ID] = cache_insert_id(); 
    printf("New account registered. ID: %d", pInfo[playerid][ID]); 
    return 1;
}
public OnGameModeInit()
{
    SQL_Connect();
	mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); 
	mysql = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD);
	if(mysql_errno(mysql) != 0) print("Could not connect to database!");
	ManualVehicleEngineAndLights();
	new rcon[80];
	format(rcon, sizeof(rcon), "hostname %s", SERVER_NAME);
	SendRconCommand(rcon);
	format(rcon, sizeof(rcon), "weburl %s", SERVER_URL);
	SendRconCommand(rcon);
	format(rcon, sizeof(rcon), "map %s", SERVER_MAP);
	SendRconCommand(rcon);
	SetGameModeText(SERVER_REVISION);
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case dlogin:
	    {
	        if(!response) Kick(playerid);
	        new hpass[129];
            new query[100];
	        WP_Hash(hpass, 129, inputtext);
	        if(!strcmp(hpass, pInfo[playerid][Password]))
	        {
	            mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
				mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
			}
			else 
			{
				ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
			}
		}
		case dregister: 
		{
		    if(!response) return Kick(playerid); 
		    if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
   			new query[300];
			WP_Hash(pInfo[playerid][Password], 129, inputtext); 
			mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `Moderator`, `Helper`, `Gold`, `Money`, `Skin`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0)", Name[playerid], pInfo[playerid][Password], IP[playerid]);
			mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
		}
	}
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
	{
 		new playerb = pInfo[playerid][pSpectator];
		new string[128];
		if(playerb != INVALID_PLAYER_ID)
  	{
   		new ip[16], Float:H, Float:A;
     	GetPlayerIp(playerb, ip, sizeof(ip));
     	GetPlayerHealth(playerb, H); GetPlayerArmour(playerb, A);
     	format(string, sizeof(string), "Name: %s         Health: %0.1f         Armour: %0.1f         Money: %d         IP: %s", Lname(playerb), H, A, GetPlayerMoney(playerb), ip);
     	TextDrawSetString(Stats1[playerid], string);
	    format(string, sizeof(string), "%s", pInfo[playerb][CMD1]);
	    TextDrawSetString(SpecCmd1[playerid], string);
	    format(string, sizeof(string), "%s", pInfo[playerb][CMD2]);
	    TextDrawSetString(SpecCmd2[playerid], string);
	    format(string, sizeof(string), "%s", pInfo[playerb][CMD3]);
     	TextDrawSetString(SpecCmd3[playerid], string);
     	format(string, sizeof(string), "%s", pInfo[playerb][CMD4]);
     	TextDrawSetString(SpecCmd4[playerid], string);
     	format(string, sizeof(string), "%s", pInfo[playerb][CMD5]);
     	TextDrawSetString(SpecCmd5[playerid], string);
	}
}
	return 1;
}
//general commands

CMD:help(playerid, params[])
{
	SendClientMessage(playerid, COLOR_YELLOW, "{FFA500}. : : {FFFF00}Luxury Help Commands {FFA500}: : .");
	SendClientMessage(playerid, SERVERCOLOR, "General: /me, /do, /s(shout), /l(low), /pm, /blockpm");
	return 1;
}

CMD:me(playerid, params[])
{
        new
        	string[128],
      		action[100];
      		
        if(sscanf(params, "s[100]", action))
        {
            SendClientMessage(playerid, -1, "USAGE: /me [action]");
            return 1;
        }
        else
        {
            format(string, sizeof(string), "%s %s", Lname(playerid), action);
            ProxDetector(30, playerid, string, COLOR_PURPLE);
        }
        return 1;
}

CMD:do(playerid, params[])
{
        new
        	string[128],
         	action[100];
         	
        if(sscanf(params, "s[100]", action))
        {
            SendClientMessage(playerid, -1, "USAGE: /do [action]");
            return 1;
        }
        else
        {
            format(string, sizeof(string), "%s (( %s ))", action, Lname(playerid));
            ProxDetector(30, playerid, string, COLOR_PURPLE);
        }
        return 1;
}

CMD:s(playerid, params[]) return cmd_shout(playerid, params);
CMD:shout(playerid, params[])
{
        new
            string[128],
            shout[100];
        if(sscanf(params, "s[100]", shout))
        {
            SendClientMessage(playerid, -1, "USAGE: /(s)hout [message]");
            return 1;
        }
        else
        {
            format(string, sizeof(string), "%s shouts: %s!",Lname(playerid),shout);
            ProxDetector(50.0, playerid, string, -1);
        }
        return 1;
}
CMD:l(playerid, params[]) return cmd_low(playerid, params);
CMD:low(playerid, params[])
{


	if (isnull(params))
	    return SendClientMessage(playerid, COLOR_GREY, "/(l)ow [low text]");

	if (strlen(params) > 64) {
	    SendNearbyMessage(playerid, 5.0, COLOR_WHITE, "%s says: %.64s", Lname(playerid), params);
	    SendNearbyMessage(playerid, 5.0, COLOR_WHITE, "...%s", params[64]);
	}
	else {
	    SendNearbyMessage(playerid, 5.0, COLOR_WHITE, "%s says: %s", Lname(playerid), params);
	}
	return 1;
}

CMD:pm(playerid, params[])
{
    new str2[128], id;
    if(sscanf(params, "us[128]", id, str2)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm [ID] [MESSAGE]");
    if(!IsPlayerConnected(id)) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~ERROR: Player Isnt Connected", 3000, 3);
    if(playerid == id) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~You can't PM your self", 3000, 3);
    if(GetPVarInt(id, "BlockPM") == 1) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Player has blocked their PM's", 3000, 3);
    new Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "((PM To %s: %s))", Name2, str2);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "((PM From %s: %s))", Name1, str2);
    SendClientMessage(id, COLOR_YELLOW, str);
    return 1;
}

CMD:blockpm(playerid, params[])
{
    if(GetPVarInt(playerid, "BlockPM") == 1)
    {
        SetPVarInt(playerid, "BlockPM", 0);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~You've unblocked your PM's", 3000, 3);
    }
    else
    {
        SetPVarInt(playerid, "BlockPM", 1);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~You've blocked your PM's", 3000, 3);
    }
    return 1;
}

CMD:staff(playerid, params[])
{
	static
		string[128];
	SendClientMessageEx(playerid,COLOR_ORANGE, ". : : Administrators : : .");
    foreach(Player, i)
    {
        if(pInfo[i][Admin])
        {
            if(abusy[i] == 0 && ahide[i] == 0)
            {
                    format(string, sizeof(string), "Name: %s Level: %d {33CC33}(Available)", Lname(i),pInfo[i][Admin]);
                    SendClientMessage(playerid, SERVERCOLOR, string);
            }
 			else if(abusy[i] == 1)
			{
   					format(string, sizeof(string), "Name: %s Level: %d {FF0000}(Busy)", Lname(i),pInfo[i][Admin]);
                    SendClientMessage(playerid, SERVERCOLOR, string);
            }
            else if(ahide[i] == 1)
            {
            }
        }
    }
    SendClientMessageEx(playerid,COLOR_ORANGE, ". : : Moderators : : .");
    foreach(Player, i)
    {
        if(pInfo[i][Moderator])
        {
            if(ahide[i] == 0 && abusy[i] == 0)
            {
                    format(string, sizeof(string), "Name: %s {33CC33}(Available)", Lname(i));
                    SendClientMessage(playerid, SERVERCOLOR, string);
            }
 			else if(abusy[i] == 1)
			{
   					format(string, sizeof(string), "Name: %s {FF0000}(Busy)", Lname(i));
                    SendClientMessage(playerid, SERVERCOLOR, string);
            }
            else if(ahide[i] == 1)
            {
            }
        }
    }
    SendClientMessage(playerid,COLOR_ORANGE, ". : : Helper : : ." );
    foreach(Player, i)
    {
        if(pInfo[i][Helper])
		{
			if (abusy[i] == 0)
        	{
                	format(string, sizeof(string), "Name: %s {33CC33}(Available)", Lname(i));
               	 	SendClientMessage(playerid, SERVERCOLOR, string);
        	}
			else if(abusy[i] == 1)
			{
					format(string, sizeof(string), "Name: %s {FF0000}(Busy)", Lname(i));
   					SendClientMessage(playerid, SERVERCOLOR, string);
      		}
    	}
    }
    return 1;
}


//faction commands

//admin+moderator commands

CMD:makeadmin(playerid, params[])
{
	static
		playerb,
	    level;

	if (pInfo[playerid][Admin] > 6)
	    return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command.");

	if (sscanf(params, "ud", playerb, level))
		return SendClientMessageEx(playerid, COLOR_WHITE, "/makeadmin [playerid/name] [level]");

	if (playerb == INVALID_PLAYER_ID)
	    return SendClientMessageEx(playerid, COLOR_WHITE, "You have specified an invalid player.");

	if (level < 0 || level > 6)
	    return SendClientMessageEx(playerid, COLOR_WHITE, "Invalid admin level. Levels range from 0 to 6.");

	if (level > pInfo[playerb][Admin])
	{
	    SendClientMessageEx(playerid, ADMINBLUE, "You have promoted %s to a higher admin level (%d).", Lname(playerb), level);
	    SendClientMessageEx(playerb, ADMINBLUE, "%s has promoted you to a higher admin level (%d).", Lname(playerid), level);
	}
	else
	{
	    SendClientMessageEx(playerid, ADMINBLUE, "You have demoted %s to a lower admin level (%d).", Lname(playerb), level);
	    SendClientMessageEx(playerb, ADMINBLUE, "%s has demoted you to a lower admin level (%d).", Lname(playerid), level);
	}
	pInfo[playerb][Admin] = level;
	return 1;
}

CMD:makemoderator(playerid, params[])
{
	static
	    playerb;

	if(pInfo[playerid][Admin] > 6) return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if(sscanf(params, "u", playerb)) return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/makemoderator [playerid/name]");
	{
		SendClientMessageEx(playerid, ADMINBLUE, "You have promoted %s to an Moderator", Lname(playerb));
		SendClientMessageEx(playerb, ADMINBLUE, "You've been promoted by %s to an Moderator Congratulations", Lname(playerid));
		pInfo[playerb][Moderator] = 1;
	}
 	return 1;
}

CMD:removemoderator(playerid, params[])
{
	static
	    playerb;

	if(pInfo[playerid][Admin] > 6) return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if(sscanf(params, "u", playerb)) return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/removemoderator [playerid/name]");
	{
		SendClientMessageEx(playerid, ADMINBLUE, "You have Fired %s from the Moderator Team", Lname(playerb));
		SendClientMessageEx(playerb, ADMINBLUE, "You've been fired by %s from the Moderator Team", Lname(playerid));
		pInfo[playerb][Moderator] = 0;
	}
	return 1;
}

CMD:makehelper(playerid, params[])
{
	static
	    playerb;

	if(pInfo[playerid][Admin] > 6) return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if(sscanf(params, "u", playerb)) return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/makehelper [playerid/name]");
	{
		SendClientMessageEx(playerid, ADMINBLUE, "You have promoted %s to an Helper", Lname(playerb));
		SendClientMessageEx(playerb, ADMINBLUE, "You've been promoted by %s to an Helper Congratulations", Lname(playerid));
		pInfo[playerb][Moderator] = 1;
	}
 	return 1;
}

CMD:removehelper(playerid, params[])
{
	static
	    playerb;

	if(pInfo[playerid][Admin] > 6) return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if(sscanf(params, "u", playerb)) return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/removehelper [playerid/name]");
	{
		SendClientMessageEx(playerid, ADMINBLUE, "You have Fired %s from the Helper Team", Lname(playerb));
		SendClientMessageEx(playerb, ADMINBLUE, "You've been fired by %s from the Helper Team", Lname(playerid));
		pInfo[playerb][Moderator] = 0;
	}
	return 1;
}

CMD:apm(playerid, params[])
{
	static
	    playerb,
		string[128];

	if(pInfo[playerid][Admin] < 1)
 		return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if (sscanf(params, "us[128]", playerb, string))
	 	return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/apm [playerid/name] [text]");
	{
	    SendClientMessageEx(playerid, COLOR_ORANGE, "[APM] %s: %s", Lname(playerb), string);
	    SendClientMessageEx(playerb, COLOR_RED, "Admin: %s", string);
	}
	return 1;
}

CMD:test(playerid, params[])
{
	pInfo[playerid][Admin] = 6;
	return 1;
}

CMD:mpm(playerid, params[])
{
	static
	    playerb,
	    string[128];
	    
	if(!pInfo[playerid][Moderator])
		return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	if (sscanf(params, "us[128]", playerb, string))
		return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/mpm [playerid/name] [text]");
	{
	    SendClientMessageEx(playerid, COLOR_ORANGE, "[MPM] %s: %s", Lname(playerb), string);
	    SendClientMessageEx(playerb, COLOR_PURPLE, "Moderator: %s", string);
	}
	return 1;
}

CMD:skin(playerid, params[])
{
	static
	    userid,
		skinid;

    if (pInfo[playerid][Admin] < 1)
	    return SendClientMessage(playerid,COLOR_WHITE, "You don't have permission to use this command.");

	if (sscanf(params, "ud", userid, skinid))
	    return SendClientMessage(playerid,COLOR_WHITE, "/skin [playerid/name] [skin id]");

    if (userid == INVALID_PLAYER_ID)
	    return SendClientMessage(playerid,COLOR_WHITE, "You have specified an invalid player.");

	if (skinid < 0 || skinid > 299)
	    return SendClientMessage(playerid,COLOR_WHITE, "Invalid skin ID. Skins range from 0 to 299.");

	SetPlayerSkin(userid, skinid);
	pInfo[userid][Skin] = skinid;

	SendClientMessageEx(playerid, COLOR_WHITE, "You have set %s's skin to ID: %d.", Lname(userid), skinid);
	SendClientMessageEx(userid, COLOR_WHITE, "%s has set your skin to ID: %d.", Lname(playerid), skinid);

	return 1;
}


CMD:spec(playerid, params[])
{
	new playerb;

	if (pInfo[playerid][Admin] < 1 && pInfo[playerid][Moderator])
	    return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command.");

	if (!isnull(params) && !strcmp(params, "off", true))
	{
	    if (GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
			return SendClientMessageEx(playerid, COLOR_WHITE, "You are not spectating any player.");

	    PlayerSpectatePlayer(playerid, INVALID_PLAYER_ID);
	    PlayerSpectateVehicle(playerid, INVALID_VEHICLE_ID);

	    GetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ]);
	    pInfo[playerid][Skin] = GetPlayerSkin(playerid);
	    TogglePlayerSpectating(playerid, false);
        TextDrawHideForPlayer(playerid, Stats1[playerid]);
        TextDrawHideForPlayer(playerid, SpecCmd1[playerid]);
        TextDrawHideForPlayer(playerid, SpecCmd2[playerid]);
        TextDrawHideForPlayer(playerid, SpecCmd3[playerid]);
        TextDrawHideForPlayer(playerid, SpecCmd4[playerid]);
        TextDrawHideForPlayer(playerid, SpecCmd5[playerid]);
		TextDrawHideForPlayer(playerid, Text:SpecCMDBG);
		TextDrawHideForPlayer(playerid, Text:SpecLastCMD);

	    return SendClientMessageEx(playerid, COLOR_WHITE, "You are no longer in spectator mode.");
	}
	if (sscanf(params, "u", playerb))
		return SendClientMessageEx(playerid, COLOR_WHITE, "/spectate [playerid/name] - Type \"/spectate off\" to stop spectating.");

	if (playerb == INVALID_PLAYER_ID)
	    return SendClientMessageEx(playerid, COLOR_WHITE, "You have specified an invalid player.");

	if (GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
	{
		GetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ]);

		pInfo[playerid][pInterior] = GetPlayerInterior(playerid);
		pInfo[playerid][pWorld] = GetPlayerVirtualWorld(playerid);
	}
 	TextDrawShowForPlayer(playerid, Stats1[playerid]);
    TextDrawShowForPlayer(playerid, Text:SpecCmd1[playerid]);
	TextDrawShowForPlayer(playerid, Text:SpecCmd2[playerid]);
	TextDrawShowForPlayer(playerid, Text:SpecCmd3[playerid]);
	TextDrawShowForPlayer(playerid, Text:SpecCmd4[playerid]);
	TextDrawShowForPlayer(playerid, Text:SpecCmd5[playerid]);
 	TextDrawShowForPlayer(playerid, Text:SpecCMDBG);
  	TextDrawShowForPlayer(playerid, Text:SpecLastCMD);

	SetPlayerInterior(playerid, GetPlayerInterior(playerb));
	SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));

	TogglePlayerSpectating(playerid, 1);

	if (IsPlayerInAnyVehicle(playerb))
	    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(playerb));

	else
		PlayerSpectatePlayer(playerid, playerb);

	SendClientMessageEx(playerid, COLOR_WHITE, "You are now spectating %s (ID: %d).", Lname(playerb), playerb);
	pInfo[playerid][pSpectator] = playerb;

	return 1;
}

CMD:goto(playerid, params[])
{
	new playerb, string[128], Float: ToX, Float: ToY, Float: ToZ;
	if(sscanf(params, "u", playerb)) return SendClientMessageEx(playerid, COLOR_WHITE, "[USAGE]/goto [playerid/name]");
	{
	    if(pInfo[playerid][Admin] >= 1) return SendClientMessageEx(playerid, COLOR_WHITE, "You don't have permission to use this command");
	    {
			SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /goto [playerid]");
		}
		if(pInfo[playerid][Admin] > 1)
		{
		    if(IsPlayerConnected(playerb))
		    {
					GetPlayerPos(playerb, ToX, ToY, ToZ);
					new VW = GetPlayerVirtualWorld(playerb);
					new INT = GetPlayerInterior(playerb);
					SetPlayerPos(playerid, ToX, ToY, ToZ);
					SetPlayerVirtualWorld(playerid, VW);
					SetPlayerInterior(playerid, INT);
					format(string, sizeof(string), "You have teleported to %s.", Lname(playerb));
					SendClientMessage(playerid, COLOR_WHITE, string);
			}
		}
	}
	return 1;
}
CMD:airport(playerid, params[])
{
    SetPlayerPos(playerid, 1642.1957, -2334.4849, 13.5469);
    return 1;
}

CMD:ahide(playerid, params[])
{
    if (!pInfo[playerid][Admin] && !pInfo[playerid][Moderator])
	    return SendClientMessageEx(playerid, COLOR_GREY, "You don't have permission to use this command.");

	switch (ahide[playerid])
	{
	    case 0:
	    {
	        ahide[playerid] = 1;
	        SendClientMessageEx(playerid, SERVERCOLOR, "You are now hidden from the staff list.");
		}
		case 1:
	    {
	        ahide[playerid] = 0;
	        SendClientMessageEx(playerid, SERVERCOLOR, "You are now visible in the staff list.");
		}
	}
	return 1;
}

CMD:abusy(playerid, params[])
{
    if (!pInfo[playerid][Admin] && !pInfo[playerid][Moderator] && !pInfo[playerid][Helper])
    	return SendClientMessageEx(playerid, COLOR_GREY, "You don't have permission to use this command.");

	switch (abusy[playerid])
	{
	    case 0:
	    {
	        abusy[playerid] = 1;
	        SendClientMessageEx(playerid, SERVERCOLOR, "You are now Busy on the staff list");
		 }
		 case 1:
		 {
		    abusy[playerid] = 0;
		    SendClientMessageEx(playerid, SERVERCOLOR, "You are now Available again on the Staff list");
		 }
	}
	return 1;
}

CMD:kick(playerid, params[])
{
    static
	 	playerb,
	  	string[128];
	  	
    if(pInfo[playerid][Admin] < 1 && !pInfo[playerid][Moderator])
		return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(sscanf(params, "us[128]", playerb, params))
		return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /kick [playerid] [reason]");
		
    if(!IsPlayerConnected(playerb))
	 	return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
	 	
    if(pInfo[playerid][Admin] < pInfo[playerb][Admin])
	 	return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
	 	
    format(string, sizeof(string), "[Server]: %s has been kicked by %s, reason: %s", Lname(playerb), Lname(playerid), params);
    SendClientMessageToAll(COLOR_RED, string);
    SetTimerEx("kickbugfix", 500, false, "i", playerb);
    return 1;
}


//helper commands
DRP is offline   Reply With Quote
Old 22/03/2015, 12:08 AM   #2
DRP
Big Clucker
 
Join Date: Apr 2014
Posts: 133
Reputation: 46
Default Re: Registration Problem Error

Quote:
Originally Posted by ****** View Post
Don't make a registration system, download one instead.
I have been viewing a tutorial about this, and I don't think I've done anything wrong untill I came in the moment that faced my fail in it by not being able to register, I request correction, or showing me the mistake.
DRP is offline   Reply With Quote
Old 22/03/2015, 12:10 AM   #3
mirou123
Huge Clucker
 
Join Date: Jul 2013
Posts: 362
Reputation: 22
Default Re: Registration Problem Error

define not working. And also make sure you salt and hash the passwords a couple of times. Making your own encryption method to encrypt the hashed passwords can help also.
mirou123 is offline   Reply With Quote
Old 22/03/2015, 01:09 AM   #4
mirou123
Huge Clucker
 
Join Date: Jul 2013
Posts: 362
Reputation: 22
Default Re: Registration Problem Error

Quote:
Originally Posted by ****** View Post
No it can't! That's just one of the reasons I tell people not to write their own system!
How on earth adding a little bit extra security doesn't help? Sure thing it can be unencrypted but at least that will slow the hackers down a little bit. They won't get to deal with the hash straight away at least. Also why are you always asking people to download pre-made registration systems? Why do you think that those scripts will be more secure than ours? I think you should start believing in us instead of scaring us away and putting us down.
mirou123 is offline   Reply With Quote
Old 22/03/2015, 01:44 AM   #5
mirou123
Huge Clucker
 
Join Date: Jul 2013
Posts: 362
Reputation: 22
Default Re: Registration Problem Error

I know that substitution boxes allow you to alter the linearity of the encryption's structure (Not sure if that's the right way to word it, since the courses I took were in french). To make it simple, they are the reason why some of the hashes of strings with different lengths have the same length. Anyways, I use my own registration system because I couldn't find other systems that are much different of what I do. Almost all of the systems that I found so far simply use the whirlpool plugin.

I just re-read your post again and I didn't say that I am making my own hashing algorithme. I don't think that I am good enough for that. But what I mean is: for example I do the salting and everything and I get my final hashed password. I would do a basic encryption of that hash for instance make a = c, d = g etc... (Just a simple example).
I don't see why that would be a bad idea because if they try to brute force it for example they will get a wrong string.
Doing the encryption before the hashing should also work and even if a hacker breaks the hash he will need to decrypt the output and only I will know the key which makes his job slightly harder but of course not impossible. My point is, I don't see why it would hurt to do that and this what I am trying to explain and I think you misinterpreted it into making my own hashing algorithme.
mirou123 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with ID 301+ (server force acc to registration) Stereotype Scripting Help 6 24/10/2013 03:53 PM
[Error, bug ?]Last Ip, Ip registration. mysql table TheBluec0de Scripting Help 4 19/06/2012 03:44 PM
[FilterScript] [FS] ErroR's Registration System with GUI! erorcun Filterscripts 217 11/07/2010 07:56 PM


All times are GMT. The time now is 06:07 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.