house problem
#1

well i am doing a house script but when i use /entrar i cannot enter



CMD:entrar(playerid,params[])
{

new pName[24];
for(new i = 0; i < MAX_CASAS;i++)
{
if(!IsPlayerInRangeOfPoint(playerid,8.0,CInfo[i][entradax],CInfo[entraday][entraday],CInfo[i][entradaz])) continue;
GetPlayerName(playerid,pName,24);//Storing the players name
if(CInfo[i][nomedacasa] == 1 && strcmp(CInfo[i][nomedacasa],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlay erInterior(playerid));//Storing, so later we can reset it back
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetP layerVirtualWorld(playerid));//Storing, so later we can reset it back
SetPlayerInterior(playerid,12);//Setting the players interior.
SetPlayerPos(playerid,446.7281,507.0475,1001.4195) ;//Setting the players position.
SetPlayerVirtualWorld(playerid,CInfo[i][vw]);//Preventing players from different houses, finding each other.
return 1;
}
SendClientMessage(playerid,-1,"You aren't near a house!");
return 1;
}

can you help? it always saying "you arent near a house" but i am really close.
thanks if you helped me
Reply
#2

You send the message even if they are in range or not.

pawn Код:
CMD:entrar(playerid,params[])
{
   
    new pName[24], bool: inrange = false;
    for(new i = 0; i < MAX_CASAS;i++)
    {
        if(!IsPlayerInRangeOfPoint(playerid,8.0,CInfo[i][entradax],CInfo[entraday][entraday],CInfo[i][entradaz])) continue;
        GetPlayerName(playerid,pName,24);//Storing the players name
        if(CInfo[i][nomedacasa] == 1 && strcmp(CInfo[i][nomedacasa],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
        {
            SetPVarInt(playerid,"PlayersInteriorHouse",GetPlay erInterior(playerid));//Storing, so later we can reset it back
            SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetP layerVirtualWorld(playerid));//Storing, so later we can reset it back
            SetPlayerInterior(playerid,12);//Setting the players interior.
            SetPlayerPos(playerid,446.7281,507.0475,1001.4195) ;//Setting the players position.
            SetPlayerVirtualWorld(playerid,CInfo[i][vw]);//Preventing players from different houses, finding each other.
            inrange = true;
        }
    }
    if(!inrange) SendClientMessage(playerid,-1,"You aren't near a house!");
    return 1;
}
EDIT:
pawn Код:
if(CInfo[i][nomedacasa] == 1 && strcmp(CInfo[i][nomedacasa],pName) == 0)
[I]CInfo[nomedacasa] is integer or string? It should store the owner's name, shouldn't it? But you're checking if it's equal to 1 too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)