Wrong info
#1

hey guys i have a cmd /bidhouse id and it's giving me some info but the funny thing is at every owned house is giving my lastlogin timer not from the owner

Код HTML:
CMD:bidhouse(playerid, params[])
{
	new bidhouse;
	if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai gradul necesar ca sa folosesti aceasta comanda!");
	if(sscanf(params,"i",bidhouse)) return SendClientMessage(playerid, COLOR_SYN, "Sintaxa:{FFFFFF} /bidhouse <houseid>");
	{
	    if(strlen(HouseInfo[bidhouse][hOwner]) < 2) return SendClientMessage(playerid, COLOR_ERROR, "Invalid house id.");
	    if(!strcmp(HouseInfo[bidhouse][hOwner], "The State")) format(gString, sizeof(gString), "Owner: The State | House id: %d", bidhouse);
		else format(gString, sizeof(gString), "Owner: %s | House id: %d | Last Login: %s", HouseInfo[bidhouse][hOwner], bidhouse, PlayerInfo[playerid][pLastLogin]);
		SendClientMessage(playerid, COLOR_GRAD3, gString);
	}
	return 1;
}
why ?
Reply
#2

Код:
else format(gString, sizeof(gString), "Owner: %s | House id: %d | Last Login: %s", HouseInfo[bidhouse][hOwner], bidhouse, PlayerInfo[playerid][pLastLogin]);
This is why, you get the last login for the player sending the command and not the house owner. The PlayerInfo[playerid][pLastLogin] part of your format needs replacing. What you currently do is get the player sending the command's last login and using that. Seeing as this is stored on player id and house owners will not always be online, you will need to fetch the last login from database if the house owner is not connected (unless you decide to store this in houseInfo array or some other way in script, if he connected is you can use the PlayerInfo array.
Reply
#3

some idea how to do it ?
Reply
#4

Quote:
Originally Posted by StR_MaRy
Посмотреть сообщение
some idea how to do it ?
I assume playerLastLogin from the player data array is saved somewhere, you'll need to load it for offline house owners and for online you can simply just insert now as a string I guess, no need to get the last login of an online player .
Reply
#5

Information

Well this is scary, your not even protecting your array from an out of bounds error. What do you think will happen if you was to enter 9999999 as the house id? I will tell you what will happen, your code will no execute. Why? because once the server gets to that part to execute the code within the if statement, it will check to see if hOwner from house id 9999999 exists and of course 9999999 is far bigger then your house enumerator array.

Solution

Well clearly your fetching "PlayerInfo[ playerid ][pLastLogin]" and passing in your own ID. You will need to grab the mysql id for that house in your db and then grab the owner's name. then you will need to query the player data table in the db for the player name and then grab the last_login result.

Good luck with that and no i'm not going to do it for you, I have told you what you need to do so attempt to do it yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)