SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/03/2020, 06:59 PM   #1
BugsBunny
Little Clucker
 
Join Date: Mar 2014
Posts: 24
Reputation: 0
Default House Rent System problem!

When I try to kick a renter the system doesn't write his name, also wrong house id. The player doesn't get any message and the database is not updated (the query didn't start!).

Code:
Dialog:DialogRenterKick(playerid, response, listitem, inputtext[])
{
	if(!response)return 0;

	if(!IsValidRoleplayName(inputtext))return
	    Dialog_Show(playerid, DialogRenterKick, DIALOG_STYLE_INPUT, "Kick Renter", "Use Name_Surname\nInsert the name (Name_Surname) of your renter that you want to kick:", "Proceed", "Leave");

	new query[256];

	mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM characters WHERE char_name = '%e' AND banned = 0 AND deleted = 0 AND deleted_at IS NULL", inputtext);
	mysql_tquery(dbHandle, query, "OnHouseRenterKickSearch", "d", playerid);

	return 1;
}

OnHouseRenterKickSearch(playerid); public OnHouseRenterKickSearch(playerid)
{
	static rows, fields;
	cache_get_data(rows, fields, dbHandle);

	new query[128];
	new houseid = GetPlayerMenuHouse(playerid);

	if(!rows || cache_get_field_content_int(0, "house") != houseid)return
	 	SendClientMessageEx(playerid, COLOR_ERROR, "This player is not your renter.");

    new name[MAX_PLAYER_NAME];
    new tmpID;

	cache_get_field_content(0, "char_name", name, dbHandle, MAX_PLAYER_NAME);
	tmpID = cache_get_field_content_int(0, "id");

	mysql_format(dbHandle, query, sizeof(query), "UPDATE characters SET house = '-1', house_price = '-1' WHERE id = '%d'", tmpID);
	mysql_tquery(dbHandle, query);

	foreach(new id : Player)
	{
	 	if(!IsPlayerConnected(id) || id == playerid || tmpID != PlayerInfo[id][pID]) continue;
		if(PlayerInfo[id][pHouse] != houseid || PlayerInfo[id][pHousePrice] == -1)continue;

		SendFormattedMessage(id, COLOR_HOUSE, "%s kicked you from his house (ID: %d).", ReturnRoleplayName(playerid), PlayerInfo[playerid][pHouse]);

		PlayerInfo[id][pHouse] = -1;
		PlayerInfo[id][pHousePrice] = -1;
		if(PlayerInfo[id][pHouseSpawn] == houseid)PlayerInfo[id][pHouseSpawn] = -1;

		break;
	}

	SendFormattedMessage(playerid, COLOR_HOUSE, "You have kicked %s from your house renters (ID: %d).", name, PlayerInfo[playerid][pHouse]);

	return 1;
}
Sorry for bad english!
BugsBunny is offline   Reply With Quote
Old 29/03/2020, 07:25 PM   #2
Antarovic
Little Clucker
 
Join Date: Mar 2020
Posts: 8
Reputation: 2
Default Re: House Rent System problem!

PHP Code:
 if(!IsPlayerConnected(id) || id == playerid || tmpID != PlayerInfo[id][pID]) continue;
        if(
PlayerInfo[id][pHouse] != houseid || PlayerInfo[id][pHousePrice] == -1)continue; 
what are you trying to do in this part i need more illustration ?
and i need to see function GetPlayerMenuHouse
Antarovic is offline   Reply With Quote
Old 29/03/2020, 08:25 PM   #3
BugsBunny
Little Clucker
 
Join Date: Mar 2014
Posts: 24
Reputation: 0
Default Re: House Rent System problem!

Quote:
Originally Posted by Antarovic View Post
PHP Code:
 if(!IsPlayerConnected(id) || id == playerid || tmpID != PlayerInfo[id][pID]) continue;
        if(
PlayerInfo[id][pHouse] != houseid || PlayerInfo[id][pHousePrice] == -1)continue; 
what are you trying to do in this part i need more illustration ?
and i need to see function GetPlayerMenuHouse
Code:
GetPlayerMenuHouse(playerid, bool:inside = false)
{
	new h = GetPlayerHouse(playerid, true);
	if(h == -1 && !inside) h = GetPlayerHouse(playerid, false);
	if(h == -1) return -1;

	if(GetHouseComplexOwner(h) == PlayerInfo[playerid][pID]) return h;
	if(HasPlayerUserKey(playerid, KEY_HOUSE, HouseInfo[h][hID]) > 0) return h;
	if(PlayerInfo[playerid][pHouse] == h) return h;
	if(HouseInfo[h][hOwner] == PlayerInfo[playerid][pID]) return h;
	if(PlayerInfo[playerid][pAdminDuty]) return h;

	return -1;
}
If I have to explain, I have to illustrate you the entire database system... if you want to know other things you can see the Sublime Game gamemode, i'm editing this!
BugsBunny is offline   Reply With Quote
Old 29/03/2020, 08:32 PM   #4
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 829
Reputation: 52
Default Re: House Rent System problem!

Show us the mysql_log when you perform this command.
__________________
JasonRiggs is offline   Reply With Quote
Old 29/03/2020, 08:43 PM   #5
BugsBunny
Little Clucker
 
Join Date: Mar 2014
Posts: 24
Reputation: 0
Default Re: House Rent System problem!

Quote:
Originally Posted by JasonRiggs View Post
Show us the mysql_log when you perform this command.
Code:
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:43:37] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:55] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:55] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:59] [ERROR] cache_get_field_content_int - invalid datatype
[22:43:59] [ERROR] cache_get_field_content_int - invalid datatype
[22:44:51] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:44:51] [ERROR] cache_get_field_content_int - invalid datatype
[22:44:51] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:44:51] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:44:51] [ERROR] cache_get_field_content_int - invalid datatype
BugsBunny is offline   Reply With Quote
Old 29/03/2020, 08:49 PM   #6
Antarovic
Little Clucker
 
Join Date: Mar 2020
Posts: 8
Reputation: 2
Default Re: House Rent System problem!

you are trying to get int and the field you access is not an int so try to start from row 1 as row zero may be header or name of the column and tell us what happen .
Antarovic is offline   Reply With Quote
Old 29/03/2020, 08:58 PM   #7
BugsBunny
Little Clucker
 
Join Date: Mar 2014
Posts: 24
Reputation: 0
Default Re: House Rent System problem!

Quote:
Originally Posted by Antarovic View Post
you are trying to get int and the field you access is not an int so try to start from row 1 as row zero may be header or name of the column and tell us what happen .
Code:
[22:59:43] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[22:59:43] [ERROR] cache_get_field_content_int - invalid datatype
[22:59:43] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[22:59:43] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[22:59:43] [ERROR] cache_get_field_content_int - invalid datatype
I changed this
Code:
if(!rows || cache_get_field_content_int(0, "house") != houseid)
and this
Code:
tmpID = cache_get_field_content_int(0, "id");
from 0 to 1
BugsBunny is offline   Reply With Quote
Old 29/03/2020, 09:06 PM   #8
Antarovic
Little Clucker
 
Join Date: Mar 2020
Posts: 8
Reputation: 2
Default Re: House Rent System problem!

Quote:
Originally Posted by BugsBunny View Post
Code:
GetPlayerMenuHouse(playerid, bool:inside = false)
{
	new h = GetPlayerHouse(playerid, true);
	if(h == -1 && !inside) h = GetPlayerHouse(playerid, false);
	if(h == -1) return -1;

	if(GetHouseComplexOwner(h) == PlayerInfo[playerid][pID]) return h;
	if(HasPlayerUserKey(playerid, KEY_HOUSE, HouseInfo[h][hID]) > 0) return h;
	if(PlayerInfo[playerid][pHouse] == h) return h;
	if(HouseInfo[h][hOwner] == PlayerInfo[playerid][pID]) return h;
	if(PlayerInfo[playerid][pAdminDuty]) return h;

	return -1;
}
If I have to explain, I have to illustrate you the entire database system... if you want to know other things you can see the Sublime Game gamemode, i'm editing this!


let's take a scenario that h is returned by -1 so in the main function you posted every time in the second if in foreach you will enter the condition so no kick will happen and no message will be shown try this and till us what happen with you .
Antarovic is offline   Reply With Quote
Old 29/03/2020, 09:09 PM   #9
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 829
Reputation: 52
Default Re: House Rent System problem!

Can you please find mysql_log in your gamemode and change it to
Code:
mysql_log(ALL);
__________________
JasonRiggs is offline   Reply With Quote
Old 29/03/2020, 09:14 PM   #10
BugsBunny
Little Clucker
 
Join Date: Mar 2014
Posts: 24
Reputation: 0
Default Re: House Rent System problem!

Quote:
Originally Posted by Antarovic View Post
let's take a scenario that h is returned by -1 so in the main function you posted every time in the second if in foreach you will enter the condition so no kick will happen and no message will be shown try this and till us what happen with you .
You mean like this?
Code:
OnHouseRenterKickSearch(playerid); public OnHouseRenterKickSearch(playerid)
{
	static rows, fields;
	cache_get_data(rows, fields, dbHandle);

	new query[128];
	new houseid = GetPlayerMenuHouse(playerid);

	if(!rows || cache_get_field_content_int(1, "house") != houseid)return
	 	SendClientMessageEx(playerid, COLOR_ERROR, "This player is not your renter.");

    new name[MAX_PLAYER_NAME];
    new tmpID;

	cache_get_field_content(0, "char_name", name, dbHandle, MAX_PLAYER_NAME);
	tmpID = cache_get_field_content_int(1, "id");

	mysql_format(dbHandle, query, sizeof(query), "UPDATE characters SET house = '-1', house_price = '-1' WHERE id = '%d'", tmpID);
	mysql_tquery(dbHandle, query);

	/*foreach(new id : Player)
	{
	 	if(!IsPlayerConnected(id) || id == playerid || tmpID != PlayerInfo[id][pID]) continue;
		if(PlayerInfo[id][pHouse] != houseid || PlayerInfo[id][pHousePrice] == -1)continue;

		SendFormattedMessage(id, COLOR_HOUSE, "%s kicked you from his house (ID: %d).", ReturnRoleplayName(playerid), PlayerInfo[playerid][pHouse]);

		PlayerInfo[id][pHouse] = -1;
		PlayerInfo[id][pHousePrice] = -1;
		if(PlayerInfo[id][pHouseSpawn] == houseid)PlayerInfo[id][pHouseSpawn] = -1;

		break;
	}*/

	SendFormattedMessage(playerid, COLOR_HOUSE, "You have kicked %s from your house renters (ID: %d).", name, PlayerInfo[playerid][pHouse]);

	return 1;
}
If yes, still same messages on mysql log!
In game: You have kicked NULL from your house renters (ID: -1)
BugsBunny 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
Job System, House Rent System and Event System AngeloBrand98 Scripting Help 2 08/11/2016 07:34 AM
Rent system - problem NoDi522 Scripting Help 17 13/03/2015 10:53 PM
Gagi's House System's House cords problem Wahaj Scripting Help 2 03/07/2014 03:15 PM
Compile problem. car rent system guaid Help Archive 4 23/08/2010 11:29 PM
Help With Car Rent System Keeboo13 Help Archive 0 16/03/2010 07:52 AM


All times are GMT. The time now is 05:40 PM.


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