[HELP]: Lock house
#1

Hello again !

I am trying to make a command to lock/unlock a house, but for some reason nothing happends.

pawn Код:
CMD:lockh(playerid, params[])
{
    for(new i = 0; i < MAX_HOUSES; i ++)
    {
    if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[i][posX], HouseInfo[i][posY], HouseInfo[i][posZ])) continue;
    new pName[24]; new string[70];
    GetPlayerName(playerid, pName, 24);
    if(strcmp(pName, HouseInfo[i][Owner], true))
    {
    if(HouseInfo[i][hLock] == 0)
    {
    HouseInfo[i][hLock] = 1;
    format(string, sizeof(string), "* %s has locked his house !", GetName(playerid));
    ProxDetector(30, playerid, string, COLOR_PURPLE);
    GameTextForPlayer(playerid, "~w~house ~r~locked", 3000, 5);
    }
    if(HouseInfo[i][hLock] == 1)
    {
    HouseInfo[i][hLock] = 0;
    format(string, sizeof(string), "* %s has unlocked his house !", GetName(playerid));
    ProxDetector(30, playerid, string, COLOR_PURPLE);
    GameTextForPlayer(playerid, "~w~house ~g~unlocked", 3000, 5);
    }
    }
    }
    return 1;
}
Thanks
Reply
#2

The distance you've declared is 2 meters (2.0), maybe you're a bit far?
Reply
#3

Quote:
Originally Posted by Loot
Посмотреть сообщение
The distance you've declared is 2 meters (2.0), maybe you're a bit far?
No. I am the right point.
Reply
#4

Ok, the next check is if you're the owner, are you?
P.S Is the command returns 0?
Reply
#5

Quote:
Originally Posted by Loot
Посмотреть сообщение
Ok, the next check is if you're the owner, are you?
P.S Is the command returns 0?
Yes, i am the owner. And nothing happends when I type the command.
Reply
#6

Alright, is the house lock variable either 0 or 1?
Have you tried debugging the code? (check which number doesn't get called)

pawn Код:
CMD:lockh(playerid, params[])
{
    for(new i = 0; i < MAX_HOUSES; i ++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[i][posX], HouseInfo[i][posY], HouseInfo[i][posZ])) continue;
        new pName[24]; new string[70];
        print("1");
        GetPlayerName(playerid, pName, 24);
        print("2");
        if(strcmp(pName, HouseInfo[i][Owner], true))
        {
            print("3");
            if(HouseInfo[i][hLock] == 0)
            {
                HouseInfo[i][hLock] = 1;
                format(string, sizeof(string), "* %s has locked his house !", GetName(playerid));
                ProxDetector(30, playerid, string, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~w~house ~r~locked", 3000, 5);
                print("4");
            }
            if(HouseInfo[i][hLock] == 1)
            {
                HouseInfo[i][hLock] = 0;
                format(string, sizeof(string), "* %s has unlocked his house !", GetName(playerid));
                ProxDetector(30, playerid, string, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~w~house ~g~unlocked", 3000, 5);
                print("5");
            }
            print("6");
        }
        print("6");
    }
    return 1;
}
Reply
#7

3, 4, 5, 6 don't get called.
Reply
#8

Then looks like the comparison between the owner string and player name returned false.
Reply
#9

But how ? Owner = Areax. And my name is Areax.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)