#1

I start a new house system, all it's okay but when i try to lock my own house, doesn't work..

Code:

if(strcmp(HouseInfo[i][HouseOwnerName], name, true) == 1)
{
Reply
#2

Hello.

We need more code. Show us your command which you use to lock your house.
Reply
#3

if(strcmp(cmdtext, "/lockhouse", true) == 0)
{
for(new i = 0; i <sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][HouseExitX], HouseInfo[i][HouseExitY], HouseInfo[i][HouseExitZ]) || IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][HouseEnterX], HouseInfo[i][HouseEnterY], HouseInfo[i][HouseEnterZ]))
{
new name[255];
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(HouseInfo[i][HouseOwnerName], name, true) == 1)
{
if(HouseInfo[i][HouseLocked] == 0)
{
HouseInfo[i][HouseLocked] = 1;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: {FFFFFF}Къщата вече е заключена за посетители!");
}
else if(HouseInfo[i][HouseLocked] == 1)
{
HouseInfo[i][HouseLocked] = 0;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: {FFFFFF}Къщата вече е отключена за посетители!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Трябва да сте собственик на къщата!");
}
}
}
return 1;
}
Reply
#4

Код:
if(strcmp(cmdtext, "/lockhouse", true) == 0)
{
	for(new i = 0; i <sizeof(HouseInfo); i++)
	{
		if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][HouseExitX], HouseInfo[i][HouseExitY], HouseInfo[i][HouseExitZ]) || IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][HouseEnterX], HouseInfo[i][HouseEnterY], HouseInfo[i][HouseEnterZ]))
		{
			new name[MAX_PLAYER_ANME];
			GetPlayerName(playerid, name, sizeof(name));
			if(strcmp(HouseInfo[i][HouseOwnerName], name, true) == 0)
			{
				if(HouseInfo[i][HouseLocked] == 0)
				{
					HouseInfo[i][HouseLocked] = 1;
					SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: {FFFFFF}Къщата вече е заключена за посетители!");
				}
				else
				{
					HouseInfo[i][HouseLocked] = 0;
					SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: {FFFFFF}Къщата вече е отключена за посетители!");
				}
                                return 1;
			}
			else 
                        {
                              SendClientMessage(playerid, COLOR_GREY, "Трябва да сте собственик на къщата!");
                              return 1;
                        }
		}
	}
	return 1;
}
Reply
#5

Not working, i can unlock all houses without to be my.
Reply
#6

Are you sure about this? Try to paste the code again and try.
Reply
#7

Yes, i'm sure.....
Reply
#8

strcmp returns 0 when both strings are equals as Lucky13's code. However, it also returns 0 when either of them is empty.

PHP код:
if (strcmp(cmdtext"/lockhouse"true) == 0)
{
    new 
name[MAX_PLAYER_NAME]; // 255 is way too big, 24 is more than enough
    
GetPlayerName(playeridnamesizeof(name)); // get the name once only
    
for (new 0sizeof(HouseInfo); i++)
    {
        
// if player not in range of both interior and exterior, skip it (go to the next iteration)
        
if (!IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseExitX], HouseInfo[i][HouseExitY], HouseInfo[i][HouseExitZ]) && !IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseEnterX], HouseInfo[i][HouseEnterY], HouseInfo[i][HouseEnterZ])) continue;
        if (!
HouseInfo[i][HouseOwnerName][0]) continue; // no owner, empty variable
        
if (strcmp(HouseInfo[i][HouseOwnerName], nametrue)) return SendClientMessage(playeridCOLOR_GREY"Трябва да сте собственик на къщата!");
        if (
HouseInfo[i][HouseLocked] == 0)
        {
            
HouseInfo[i][HouseLocked] = 1;
            
SendClientMessage(playeridCOLOR_LIGHTBLUE"SERVER: {FFFFFF}Къщата вече е заключена за посетители!");
        }
        else if (
HouseInfo[i][HouseLocked] == 1)
        {
            
HouseInfo[i][HouseLocked] = 0;
            
SendClientMessage(playeridCOLOR_LIGHTBLUE"SERVER: {FFFFFF}Къщата вече е отключена за посетители!");
        }
        break; 
// stop the loop, it is not needed anymore
    
}
    return 
1// command found, don't search in other scripts

Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
strcmp returns 0 when both strings are equals as Lucky13's code. However, it also returns 0 when either of them is empty.

PHP код:
if (strcmp(cmdtext"/lockhouse"true) == 0)
{
    new 
name[MAX_PLAYER_NAME]; // 255 is way too big, 24 is more than enough
    
GetPlayerName(playeridnamesizeof(name)); // get the name once only
    
for (new 0sizeof(HouseInfo); i++)
    {
        
// if player not in range of both interior and exterior, skip it (go to the next iteration)
        
if (!IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseExitX], HouseInfo[i][HouseExitY], HouseInfo[i][HouseExitZ]) && !IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseEnterX], HouseInfo[i][HouseEnterY], HouseInfo[i][HouseEnterZ])) continue;
        if (!
HouseInfo[i][HouseOwnerName][0]) continue; // no owner, empty variable
        
if (strcmp(HouseInfo[i][HouseOwnerName], nametrue)) return SendClientMessage(playeridCOLOR_GREY"Трябва да сте собственик на къщата!");
        if (
HouseInfo[i][HouseLocked] == 0)
        {
            
HouseInfo[i][HouseLocked] = 1;
            
SendClientMessage(playeridCOLOR_LIGHTBLUE"SERVER: {FFFFFF}Къщата вече е заключена за посетители!");
        }
        else if (
HouseInfo[i][HouseLocked] == 1)
        {
            
HouseInfo[i][HouseLocked] = 0;
            
SendClientMessage(playeridCOLOR_LIGHTBLUE"SERVER: {FFFFFF}Къщата вече е отключена за посетители!");
        }
        break; 
// stop the loop, it is not needed anymore
    
}
    return 
1// command found, don't search in other scripts

Thanks!
Reply
#10

@Konstantinus:
PHP код:
 if (!IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseExitX], HouseInfo[i][HouseExitY], HouseInfo[i][HouseExitZ]) && !IsPlayerInRangeOfPoint(playerid1.0HouseInfo[i][HouseEnterX], HouseInfo[i][HouseEnterY], HouseInfo[i][HouseEnterZ])) continue; 
Is this right?
I mean , players can only be at the output OR at the entrance. Not in both places at the same time.
Sorry, when I'm false. I only want to ask because I think it's wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)