Problem with /evictbusiness (possible strcmp mistake)
#1

Hey

Idea of what the problem is:

Business created by (might be irrelevant) account: Hi_Lo
Business bought by account: Hi_Lo

Business evicted by Hi_Low when Hi_Lo was OFFLINE
[20:55:57] {F81414}WARNING:{FFFFFF} Hi_Lo (offline player) has been evicted from their business(ID:1).


The green symbolises it works as intended.

-------------------

Business purchased by account: Hi_Low

Business evicted by Hi_Lo when Hi_Low was OFFLINE
[20:58:31] {F81414}WARNING:{FFFFFF} Hi_Lo has been evicted from their business(ID:1).


The red symbolises it doesn't work as intended. It is meant to be Hi_Low being OFFLINE evicted. As opposed to Hi_Lo being ONLINE evicted (Hi_Lo did not even own it at this time - he is simply the one who executed the command).


Relevant Code:

Код:
CMD:evictbusiness(playerid, params[])
{
	new id, playername[24], string[128];

	if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_WHITE, "/evictbusiness [id]");
    if(BusinessInfo[id][bExists] == 0) return SendClientMessage(playerid, COLOR_WHITE, "invalid id");
	if(BusinessInfo[id][bOwned] == 0) return SendClientMessage(playerid, COLOR_WHITE, "no owner");
	foreach(new i : Player)
	{
	    if(IsPlayerConnected(i))
		{
		    GetPlayerName(i, playername, sizeof(playername));
      		if(strcmp(BusinessInfo[id][bOwner], playername, true, strlen(playername)) == 0)
      		{
				PlayerInfo[i][pBusinessID] = 0;
				format(string, sizeof(string), "{F81414}WARNING:{FFFFFF} %s has been evicted from their business(ID:%i).", playername, id);
				SendClientMessage(playerid, COLOR_WHITE, string);
				BusinessInfo[id][bOwner] = 0;
				BusinessInfo[id][bOwned] = 0;
				UpdateLabel(id);
				return 1;
      		}
		}
 	}
	format(string, sizeof(string), "/Users/%s.ini", BusinessInfo[id][bOwner]);
 	new INI:File = INI_Open(string);
    INI_SetTag(File,"data");
    INI_WriteInt(File,"BusinessID", 0);
    INI_Close(File);
	format(string, sizeof(string), "{F81414}WARNING:{FFFFFF} %s (offline player) has been evicted from their business(ID:%i).", BusinessInfo[id][bOwner], id);
    SendClientMessage(playerid, COLOR_WHITE, string);
    BusinessInfo[id][bOwned] = 0;
    BusinessInfo[id][bOwner] = 0;
    UpdateLabel(id);
	return 1;
}
I think the problem may be this line:
Код:
if(strcmp(BusinessInfo[id][bOwner], playername, true, strlen(playername)) == 0)
I don't think it's a problem with /buybusiness:

Код:
CMD:buybusiness(playerid, params[])
 {
     if(PlayerInfo[playerid][pBusinessID] > 0) return SendClientMessage(playerid, COLOR_WHITE, "already own one");
     new id = IsPlayerNearBizEnt(playerid);
     if(id == -1) return SendClientMessage(playerid, COLOR_WHITE, "not near one");
     if(BusinessInfo[id][bOwned] == 1) return SendClientMessage(playerid, COLOR_WHITE, "it's owned");
     if(BusinessInfo[id][bPrice] > PlayerInfo[playerid][pDollar]) return SendClientMessage(playerid, COLOR_WHITE, "need more cash");
     PlayerInfo[playerid][pBusinessID] = id;
     PlayerInfo[playerid][pDollar] -= BusinessInfo[id][bPrice];
     BusinessInfo[id][bOwned] = 1;
     BusinessInfo[id][bOwner] = GetRegularName(playerid);
     SendClientMessage(playerid, COLOR_WHITE, "success");
     UpdateLabel(id);
     return 1;
 }
Код:
stock GetRegularName(playerid)
 {
     new name[24];
     GetPlayerName(playerid, name, sizeof(name));
     return name;
 }
No errors or warnings.

I would appreciate any help. Sorry for the indentation, it's not like that in reality.
Reply
#2

I don't understand what you want exactly. You showed us the green and red errors and the code. I understand theres a problem. But what happens?
Reply
#3

Quote:

The red symbolises it doesn't work as intended. It is meant to be Hi_Low being OFFLINE evicted. As opposed to Hi_Lo being ONLINE evicted (Hi_Lo did not even own it at this time - he is simply the one who executed the command).

This

EDIT: And, of course, in this instance the variables do not change as intended.
Reply
#4

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
This

EDIT: And, of course, in this instance the variables do not change as intended.
Sorry, I misunderstood.

PHP код:
if(!strcmp(PlayerNameBusinessInfo[id][bOwner])) 
- Try this out.
Reply
#5

Ooh, I think you've fixed it. xD

I've rep'd you. Thanks for the help. Hopefully it's fixed for good though. :P
Reply
#6

No worries. Keep in mind to use it like that as for me it's easier to remember and it works all the time.

Need any help, drop me a message xD

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)