Help!
#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


Messages In This Thread
Help! - by martintasin - 07.08.2016, 17:08
Re: Help! - by Mencent - 07.08.2016, 17:23
Re: Help! - by martintasin - 07.08.2016, 17:34
Re: Help! - by Lucky13 - 07.08.2016, 17:36
Re: Help! - by martintasin - 07.08.2016, 17:58
Re: Help! - by Lucky13 - 07.08.2016, 18:02
Re: Help! - by martintasin - 07.08.2016, 18:07
Re: Help! - by Konstantinos - 07.08.2016, 18:08
Re: Help! - by martintasin - 07.08.2016, 18:15
Re: Help! - by Mencent - 07.08.2016, 18:18

Forum Jump:


Users browsing this thread: 1 Guest(s)