/buygarage spam
#1

I made a garage system
But when you /buygarage it spams the chat "You are not at a garage"

Codes of /buygarage:

pawn Код:
CMD:buygarage(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new h = 0; h < sizeof(GarageInfo); h++)
    {
        if(GarageInfo[h][gOwned] == 0 )
        {
            if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
            {
                if(GetPlayerMoney(playerid) > GarageInfo[h][gValue])
                {
                    PlayerInfo[playerid][pPgaragekey] = h;
                    GarageInfo[h][gOwned] = 1;
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    strmid(GarageInfo[h][gOwner], sendername, 0, strlen(sendername), 255);
                    GivePlayerMoney(playerid,-GarageInfo[h][gValue]);
                    SetPlayerInterior(playerid,GarageInfo[h][gHInteriorWorld]);
                    if(GarageInfo[h][gCustomInterior] == 1)
                    {
                        TogglePlayerControllable(playerid, 0);
                        GameTextForPlayer(playerid, "Loading....", 4000, 5);
                        SetPVarInt(playerid, "LoadingObjects", 1);
                        SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
                    }
                    SetPlayerPos(playerid,GarageInfo[h][gInteriorX],GarageInfo[h][gInteriorY],GarageInfo[h][gInteriorZ]);
                    GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by /exitgarage", 5000, 3);
                    SaveGarages();
                    SetPlayerVirtualWorld(playerid, h+6000);
                    DestroyDynamicPickup(GarageInfo[h][gPickupID]);
                    GarageInfo[h][gPickupID] = CreateDynamicPickup(1318, 23, GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]);
                    format(string, sizeof(string), "Garage Owned by\n %s\nID: %d",GarageInfo[h][gOwner],h);
                    UpdateDynamic3DTextLabelText(GarageInfo[h][gTextID], 0x33CCFFAA, string);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, 0x33CCFFAA, "   You don't have the cash for that!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage.");
            }
        }
        else
        {
            SendClientMessage(playerid, 0x33CCFFA, "this garage is owned!");
        }
    }
    return 1;
}
Code Which spam in chat:
pawn Код:
SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage.");

Help = +rep
Reply
#2

Код:
   for(new h = 0; h < sizeof(GarageInfo); h++) (This is the number of garages on the server)
    {
        if(GarageInfo[h][gOwned] == 0 ) (This means how many of them are not owned on the server)
        {
            if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
            {
            }
            else
            {
                SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage.");  (SendClientMessage will be called many times because if you have 2 not owned garages on the server, than it will call it 2 times, if there are 100 garages not owned than it will call this 100 times)
            }
Read the red text in the code If you still don't understand i will try to explain to you again
Reply
#3

Then how to fix it?
i know now what it means but Can you tell me how to fix it...?
Reply
#4

You basically need to get the nearest garage, and replace
pawn Код:
if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ] with the coordinates of the nearest garage.
You could use
pawn Код:
new Float:GarageDistance = GetPlayerDistanceFromPoint(playerid, GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]);
if(GarageDistance == 5)
{

}
Reply
#5

Nevermind fixed it but

This spam too:

pawn Код:
CMD:entergarage(playerid, params[])
{
    for(new h = 0; h < sizeof(GarageInfo); h++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
        {
            if(GarageInfo[playerid][gOwned] == 1 )
            {
                SetPlayerPos(playerid,GarageInfo[h][gInteriorX],GarageInfo[h][gInteriorY],GarageInfo[h][gInteriorZ]);
                GameTextForPlayer(playerid, "~w~Welcome to your garage!", 5000, 3);
            }
            else
            {
                SendClientMessage(playerid, 0x33CCFFAA, "You don't have a garage.");
            }
        }
        else
        {
            SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage to enter.");
        }
    }
    return 1;
}
Quote:

SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage to enter.");

Reply
#6

it is bugged , i can /buygarage from anywhere
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)