Disable /go command inside a house
#1

Recently I've added GarHouse System in my server (It doesn't allow people to enter someones house Visiting must be enables first)

Problem is that when Player1 is inside his house. Then Player2 try to go to Player1 using the command /go Player1.
it just teleports Player1 right beside Player2. Is it possible disable go if a player is inside a GarHouse?

Let's say if isplayerinhouse Show gametextforplayer "Player is Inside a House"


pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"{FFFF00}(/go) {FF0000}command is disabled at this moment");
    new Float:x, Float:y, Float:z,str[64],tID;
    if(sscanf(params,"u",tID)) return 0;
    GetPlayerPos(tID, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(tID));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(tID));
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else
    {
        SetPlayerInterior(playerid, GetPlayerInterior(tID));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(tID));
        SetPlayerPos(playerid, x + 1, y + 1, z + 0.5);
    }
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", getname(playerid), playerid);
    SendClientMessage(tID, 0xFFFFFFFF, str);
    return 1;
}
Reply
#2

Since the topic of the GarHouse does not exist anymore, could you paste the script (Command?) here, with which the player can enter a house?
Reply
#3

Thanks for noticing this Jeffry, Yea I forgot Garhouse doesn't exist. So here it is. Anyway the only way to Enter a House is by going in a Checkpoint. There is no command to Enter.

pawn Код:
#if GH_USE_CPS == true
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new string[256], tmpstring[50];
        foreach(Houses, h)
        {
            if(checkpointid == HouseCPOut[h])
            {
                SetPVarInt(playerid, "LastHouseCP", h);
                if(!strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE))
                {
                    SetPlayerHouseInterior(playerid, h);
                    ShowInfoBoxEx(playerid, COLOUR_INFO, I_HMENU);
                    break;
                }
                format(tmpstring, sizeof(tmpstring), "HouseKeys_%d", h);
                if(GetPVarInt(playerid, tmpstring) == 1)
                {
                    SetPlayerHouseInterior(playerid, h);
                    break;
                }
                if(strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE) && strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
                {
                    if(hInfo[h][HousePassword] == udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0: ShowInfoBox(playerid, LABELTEXT2, hInfo[h][HouseName], hInfo[h][HouseOwner], hInfo[h][HouseValue], h);
                            case 1:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                        }
                        break;
                    }
                    if(hInfo[h][HousePassword] != udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                            case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                        }
                        break;
                    }
                }
                if(!strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE) && hInfo[h][HouseValue] > 0 && GetPVarInt(playerid, "JustCreatedHouse") == 0)
                {
                    format(string, sizeof(string), HMENU_BUY_HOUSE, hInfo[h][HouseValue]);
                    ShowPlayerDialog(playerid, HOUSEMENU+4, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    break;
                }
            }
            if(checkpointid == HouseCPInt[h])
            {
                switch(GetPVarInt(playerid, "HousePreview"))
                {
                    case 0: ExitHouse(playerid, h);
                    #if GH_HINTERIOR_UPGRADE == true
                    case 1:
                    {
                        GetPVarString(playerid, "HousePrevName", tmpstring, 50);
                        format(string, sizeof(string), HMENU_BUY_HINTERIOR, tmpstring, GetPVarInt(playerid, "HousePrevValue"));
                        ShowPlayerDialog(playerid, HOUSEMENU+17, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    }
                    #endif
                }
                break;
            }
        }
    }
    return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPVarInt(playerid, "JustCreatedHouse") == 1)
    {
        foreach(Houses, h)
        {
            if(checkpointid == HouseCPOut[h])
            {
                DeletePVar(playerid, "JustCreatedHouse");
                break;
            }
        }
    }
    return 1;
}
THIS IS THE FILTERSCRIPT FOR GARHOUSE:
http://pastebin.com/RMbk1myC
Reply
#4

pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"{FFFF00}(/go) {FF0000}command is disabled at this moment");
    if(IsInHouse{ID} == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"ERROR: Stated Player is inside a house. Try again later.");
    new Float:x, Float:y, Float:z,str[64],tID;
    if(sscanf(params,"u",tID)) return 0;
    GetPlayerPos(tID, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(tID));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(tID));
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else
    {
        SetPlayerInterior(playerid, GetPlayerInterior(tID));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(tID));
        SetPlayerPos(playerid, x + 1, y + 1, z + 0.5);
    }
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", getname(playerid), playerid);
    SendClientMessage(tID, 0xFFFFFFFF, str);
    return 1;
}
This should work.
I wonder why you use sscanf twice.

Try this before trying the one above:
pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"{FFFF00}(/go) {FF0000}command is disabled at this moment");
    if(IsInHouse{tID} == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"ERROR: Stated Player is inside a house. Try again later.");
    new Float:x, Float:y, Float:z,str[64],ID;
    GetPlayerPos(ID, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(ID));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(ID));
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else
    {
        SetPlayerInterior(playerid, GetPlayerInterior(ID));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(ID));
        SetPlayerPos(playerid, x + 1, y + 1, z + 0.5);
    }
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", getname(playerid), playerid);
    SendClientMessage(tID, 0xFFFFFFFF, str);
    return 1;
}
And 'new' creates a new variable.
Reply
#5

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"{FFFF00}(/go) {FF0000}command is disabled at this moment");
    if(IsInHouse{ID} == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"ERROR: Stated Player is inside a house. Try again later.");
    new Float:x, Float:y, Float:z,str[64],tID;
    if(sscanf(params,"u",tID)) return 0;
    GetPlayerPos(tID, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(tID));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(tID));
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else
    {
        SetPlayerInterior(playerid, GetPlayerInterior(tID));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(tID));
        SetPlayerPos(playerid, x + 1, y + 1, z + 0.5);
    }
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", getname(playerid), playerid);
    SendClientMessage(tID, 0xFFFFFFFF, str);
    return 1;
}
This should work.
I wonder why you use sscanf twice.

Try this before trying the one above:
pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"{FFFF00}(/go) {FF0000}command is disabled at this moment");
    if(IsInHouse{tID} == 1) return SendClientMessage(playerid, 0xFFFFFFFF,"ERROR: Stated Player is inside a house. Try again later.");
    new Float:x, Float:y, Float:z,str[64],ID;
    GetPlayerPos(ID, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(ID));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(ID));
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else
    {
        SetPlayerInterior(playerid, GetPlayerInterior(ID));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(ID));
        SetPlayerPos(playerid, x + 1, y + 1, z + 0.5);
    }
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", getname(playerid), playerid);
    SendClientMessage(tID, 0xFFFFFFFF, str);
    return 1;
}
And 'new' creates a new variable.
I have tried first the Second one.. and I get this warnings

Код:
 error 017: undefined symbol "tID"
error 021: symbol already defined: "ID"
error 017: undefined symbol "tID"
Reply
#6

this is the easiest way, just check if player is inside an interior
pawn Код:
if(IsPlayerInAnyInterior(playerid)) return SendClientMessage(playerid, ....);
Reply
#7

Quote:
Originally Posted by MarkoN
Посмотреть сообщение
this is the easiest way, just check if player is inside an interior
pawn Код:
if(IsPlayerInAnyInterior(playerid)) return SendClientMessage(playerid, ....);
Thanks for the reply man! Yes but i'm using this in a Freeroam gamemode. Let' say if Player1 go to Cj house. Then player 2 use /go Player1. then he can't, cause player is in a interior (I'm avoiding this) I only want to disable /go command if player is in ONE OF GARHOUSE.

Hmm. Let say Player 1 is in one of Garhouse. Then Player 2 use /go Player1 then he teleports right beside player1, so what's the use of Lock house/ Disable visit
Reply
#8

create a variable
like
pawn Код:
new isplayeringarhouse[MAX_PLAYERS];
//so when a player is in that garhouse add
isplayeringarhouse[playerid] = 1;
// then when a player types go
if(isplayeringarhouse[i] == 1)
{
SendClientMessage(playerid, ........)
// fill in the rest, and then when you close it add else and teleport him
Reply
#9

Quote:
Originally Posted by MarkoN
Посмотреть сообщение
create a variable
like
pawn Код:
new isplayeringarhouse[MAX_PLAYERS];
//so when a player is in that garhouse add
isplayeringarhouse[playerid] = 1;
// then when a player types go
if(isplayeringarhouse[i] == 1)
{
SendClientMessage(playerid, ........)
// fill in the rest, and then when you close it add else and teleport him
Thanks for this! Anyway I don't know where I will put isplayeringarhouse[playerid] = 1; in GarHouse Filterscript I'm not sure if it in OnplayerEnterDynamicCP.
Reply
#10

no at the /go command , and you place it for that ID that the player is going to , or place the /go command here and ill make it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)