Enum problem Register/Login system
#1

I have created mysql based Register/Login and i'm using enum to store the information about the player.. And there is a strange bug with enum or smth.... When i assign my values to enum ....... code examples:
Код:
enum player_info {
	id,
	nickname[MAX_PLAYER_NAME],
	password[32],
	ipaddress[16],
	level[1],
	oskin[3],
	jskin[3],
	job[20],
	cmoney[9],
	bmoney[10],
	gender[6],
	blocked[1],
	blockedr[30]
};
Код:
new playerinfo[MAX_PLAYERS][player_info];
	new playerinfoquery[256];
	new getplayerinfo[12][128];
	GetPlayerName(playerid, playerinfo[playerid][nickname], MAX_PLAYER_NAME);
	format(playerinfoquery, sizeof(playerinfoquery), "SELECT id,password,ipaddress,level,oskin,jskin,job,cmoney,bmoney,gender,blocked,blockedr FROM `users` WHERE `nickname` = '%s' LIMIT 1", playerinfo[playerid][nickname]);
	samp_mysql_query(playerinfoquery);
	samp_mysql_store_result();
	if (samp_mysql_num_rows() == 1) {
		samp_mysql_fetch_row(playerinfoquery);
		split(playerinfoquery, getplayerinfo, '|');
		playerinfo[playerid][id] = strval(getplayerinfo[0]);
		playerinfo[playerid][password] = strval(getplayerinfo[1]);
		playerinfo[playerid][ipaddress] = strval(getplayerinfo[2]);
		playerinfo[playerid][level] = strval(getplayerinfo[3]);
		playerinfo[playerid][oskin] = strval(getplayerinfo[4]);
		playerinfo[playerid][jskin] = strval(getplayerinfo[5]);
		playerinfo[playerid][job] = strval(getplayerinfo[6]);
		playerinfo[playerid][cmoney] = strval(getplayerinfo[7]);
		playerinfo[playerid][bmoney] = strval(getplayerinfo[8]);
		playerinfo[playerid][gender] = strval(getplayerinfo[9]);
		playerinfo[playerid][blocked] = strval(getplayerinfo[10]);
		playerinfo[playerid][blockedr] = strval(getplayerinfo[11]);
everything works fine this way, but if i try to assign the value to array like that :
Код:
 playerinfo[playerid][blocked] = getplayerinfo[10];
i get an error:
Код:
C:\Kita\Deivido\Samp\Naujas\gamemodes\ruined.pwn(627) : error 047: array sizes do not match, or destination array is too small
I didin't needed to do this when i did the system on seperate arrays, not on enum.
I can't compare them like:
Код:
if (playerinfo[playerid][job] == 'Smth') {
returns me an error about array sizes..
So what should i do so that my life become easier and i can use them simply as normal array, or give me an advice how to use enum...
------------------------------------------------------------------------------------------------------
Also another question is, what's wrong here:
Код:
public isPlayerInLeaveCityZone() {
	new Float:x, Float:y, Float:z;
 	for (players=0; players < MAX_PLAYERS; players++) {
		GetPlayerPos(players, x, y, z);
		if (x <= 2128.6323 && x >= 2125.6035 && y <= 46.8678 && y >= 36.4518) {
			new warningmessage[128];
			format (warningmessage, sizeof(warningmessage), "Tau dar nelaikas palikti рб miestа, liko dar daug ko nuveikti.");
			SendClientMessage(players, COLOR_SERVER, warningmessage);
		} else {
			new warningmessage[128];
			format (warningmessage, sizeof(warningmessage), "Test");
			SendClientMessage(players, COLOR_SERVER, warningmessage);
		}
	}
	return 1;
}
Timer is set OnGameModeInit, but it doesn't return me any message, either true or false one... Is the code valid?

Reply
#2

From what I can see in your enum is that you're probably trying to assign integers to arrays ...
Reply
#3

Some of them are integers some of them are strings, and that your sentence doesn't give me any help, please be more specific
Reply
#4

second question:
Код:
public isPlayerInLeaveCityZone() {
SendClientMessageToAll(COLOR_SERVER,"gtest");
new Float:x, Float:y, Float:z;
for (players=0; players < MAX_PLAYERS; players++) {
if(!IsPlayerConnected(players)) continue;
GetPlayerPos(players, x, y, z);
if (x <= 2128.6323 && x >= 2125.6035 && y <= 46.8678 && y >= 36.4518) {
new warningmessage[128];
format (warningmessage, sizeof(warningmessage), "Tau dar nelaikas palikti рб miestа, liko dar daug ko nuveikti.");
SendClientMessage(players, COLOR_SERVER, warningmessage);
} else {
new warningmessage[128];
format (warningmessage, sizeof(warningmessage), "Test");
SendClientMessage(players, COLOR_SERVER, warningmessage);
} } return 1;
}
Reply
#5

Nothing happens, i guess it's timer fault, what's wrong with it :
Код:
public OnGameModeInit() {
   SetTimer("IsPlayerInLeaveCityZone", 1000, 1);
}
Reply
#6

Код:
("IsPlayerInLeaveCityZone"
It's the problem, you can find the error yoursefl now
Reply
#7

Quote:
Originally Posted by Paranoja
Some of them are integers some of them are strings, and that your sentence doesn't give me any help, please be more specific
Well judging by your use of strval, all of them are integers.
https://sampwiki.blast.hk/wiki/Functiontrval#strval

Quote:
Originally Posted by Vince
From what I can see in your enum is that you're probably trying to assign integers to arrays ...
Exactly. Which you can do, but in this case it is absolutely unnecessary (except for 'nickname', 'password', and 'ip').
Reply
#8

Quote:
Originally Posted by yezizhu
Код:
("IsPlayerInLeaveCityZone"
It's the problem, you can find the error yoursefl now
Thank you, solved. Didin't saw that upper case letter...


If i remove strval, than it gives me an error about the size of array:
Код:
C:\Kita\Deivido\Samp\Naujas\gamemodes\ruined.pwn(141) : warning 202: number of arguments does not match definition
So which function should i use for string?
As far as i know at the momeny
strval = integers
float = for coordinates, goes in decimals


EDIT: SOLVED all the problems with:
Код:
format(playercar[cars][car_owner],256,"%s",usercar[0]);
Thank you everyone for trying to help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)