SetPvar and GetPvar
#1

I've been working with this one for half minutes but still failing. Here it is..

First I want to disable using go command if player is inside any GarHouse (GarHouse is a Filterscript)
Here is my go command

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(GetPVarInt(playerid, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
    new Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME], str[64], i, vw; //creates new variables to store floats, strings and values
    GetPlayerPos(ID, x, y, z);//gets the player id(which we have entered after /goto position and like saves them into x,y,z defined above as floats
    i = GetPlayerInterior(ID);
    vw = GetPlayerVirtualWorld(ID);
    if(i) SetPlayerInterior(playerid, i);
    if(vw) SetPlayerVirtualWorld(playerid, vw);
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(i)
        {
            LinkVehicleToInterior(GetPlayerVehicleID(playerid), i);
            DestroyVehicle(GetPlayerVehicleID(playerid));
        }
        if(vw) SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), vw);
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z + 0.5);
    }
    else SetPlayerPos(playerid, x + 1, y + 1, z);
    return 1;
}
As you can see above I have already made a
Код:
    if(GetPVarInt(playerid, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
to check if player is inside a Garhouse.

This is for the GarHouse...
There is a note written about GetPVarInt
Quote:

// - [Script] IsInHouse "char" array for increased speed (compared to checking if a player is in a house using GetPVarInt. However you can still access the IsInHouse PVar in other scripts using GetPVarInt).

To check if player is inside a Garhouse
pawn Код:
//==============================================================================
// SetPlayerHouseInterior(playerid, house);
// This function is used to set the correct house interior for a player when he enters a house or buy a new house interior.
//==============================================================================
stock SetPlayerHouseInterior(playerid, houseid)
{
    new _int = hInfo[houseid][HouseInterior];
    SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
    SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
    SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
}
Here you can see
Код:
SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
If i'm not wrong it tell me that If I do /go to a player that is inside a GarHouse. It should say "Player is in a House" Right??




MY Problem is that when a Player 1 is inside a GarHouse and Player 2 use, /go Player 1 and it works it teleports Player 2 right beside Player 1 and that must be disabled! Coz I already get the Get and Set the pVars.

Anyone mind helping me?


Here's the Garhouse pastebin http://pastebin.com/RMbk1myC

I don't know if i'm setting it wrong or something..
Reply
#2

PVars take up more memory than regular variables and you shouldn't use them unless you're doing some cross script stuff.
Reply
#3

try
pawn Код:
if(GetPVarInt(ID, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
instead of
pawn Код:
if(GetPVarInt(playerid, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
Reply
#4

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
PVars take up more memory than regular variables and you shouldn't use them unless you're doing some cross script stuff.
You I should use Regular variables like this?

Код:
new pInEvent[MAX_PLAYERS];

IsInaHouse[playerid] = 1;
IsInaHouse[playerid] = 0;


if(IsInaHouse[ID] == 1) return GameTextForPlayer(playerid,"Player is in House",2000,3);
I have also noticed that when I changed == 1 to
Код:
if(GetPVarInt(playerid, "IsInHouse") == 0) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
The go disabled inside a GarHouse ALSO if you are not in a house or Interior 0. I can Only say it works if you use == 0 but it also disable go when you are not in any itnerior or house.
Reply
#5

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
try
pawn Код:
if(GetPVarInt(ID, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
instead of
pawn Код:
if(GetPVarInt(playerid, "IsInHouse") == 1) return GameTextForPlayer(playerid,"Player is in a House",2000,3);
DAMN SOLVED!!! NICE!! After 3000 strings the problem is playerid to ID. Omg well thanks scripting
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)