SA-MP Forums Archive
[FilterScript] Turn on/off the light in the house... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Turn on/off the light in the house... (/showthread.php?tid=486933)

Pages: 1 2


Turn on/off the light in the house... - TheSy - 11.01.2014

This script will allow you to get the impression of turning on/off the light using textdraws.
You will feel like being in the dark when you йteignerez light and be "normal" when lit.
You can do different things with this script as electricity each payday, and if the player does not pay it no longer lights etc..

The global variable:

pawn Код:
new Text:Player_lights[MAX_PLAYERS];
Under the variable added:

pawn Код:
#define MAX_HOUSE 100
pawn Код:
enum House_informations
{
    House_Lights
};
new House_Infos[MAX_HOUSE][House_informations];
pawn Код:
forward House_update(i);
In OnGameModeInit:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
        Player_lights[i] = TextDrawCreate(0.0, 0.0, "|");
        TextDrawUseBox(Player_lights[i], 1);
        TextDrawBoxColor(Player_lights[i], 0x000000BB);
        TextDrawTextSize(Player_lights[i], 660.000000, 22.000000);
        TextDrawAlignment(Player_lights[i], 0);
        TextDrawBackgroundColor(Player_lights[i], 0x000000FF);
        TextDrawFont(Player_lights[i], 3);
        TextDrawLetterSize(Player_lights[i], 1.000000, 52.200000);
        TextDrawColor(Player_lights[i], 0x000000FF);
        TextDrawSetOutline(Player_lights[i], 1);
        TextDrawSetProportional(Player_lights[i], 1);
        TextDrawSetShadow(Player_lights[i], 1);
}
For my part I do the action off/turn on the light in a single order, you way later to do as you wish.

pawn Код:
if(strcmp(cmd, "/lightshouse", true) == 0)
{
        if(Player_infos[playerid][p_InHouse] == -1) // The variable that determines whether or not you are in the house.
        {
            SendClientMessage(playerid, YOUR_COLOR, "You must be in a house to write this command.");
            return 1;
        }
        new h = Player_infos[playerid][p_InHouse];
        if(House_Infos[h][House_Lights] == 0)
        {
            House_Infos[h][House_Lights] = 1;
            House_update(h);
            SendClientMessage(playerid, YOUR_COLOR, "The light has been lit.");
            for(i = 0; i < MAX_PLAYERS; i++)
            {
                if(Player_infos[i][p_InHouse] == h)
                {
                    TextDrawHideForPlayer(i, Player_lights[i]);
                }
            }
            return 1;
         }
         else
         {
             House_infos[h][House_Lights] = 0;
             House_update(h);
             SendClientMessage(playerid, YOUR_COLOR, "The light has been extinguished.");
             for(i = 0; i < MAX_PLAYERS; i++)
             {
                 if(Player_infos[i][p_InHouse] == h)
                 {
                     TextDrawShowForPlayer(playerid, Player_lights[playerid]);
                 }
             }
             return 1;
          }
}
pawn Код:
public House_update(i)
{
          new Requete[1024], Owner[MAX_PLAYER_NAME*4];
          mysql_real_escape_string(House_infos[i][Owner], Owner);
          format(Requete, sizeof(Requete), "UPDATE House SET `Owner`='%s', `Lights`='%d' WHERE id=%d",
          House_infos[i][House_Lights],
          i);
          mysql_query(Requete);
          return 1;
}
If you have any problems with the script, do not hesitate to ask about it here or by private courier.

TheSy.


Re: Turn on/off the light in the house... - ViciousRoleplay123 - 11.01.2014

Good. +rep


Re : Turn on/off the light in the house... - TheSy - 11.01.2014

Thanks.


Re: Turn on/off the light in the house... - Yves - 11.01.2014

good job very neat 2 reps.


Re: Turn on/off the light in the house... - KingServerIRAN - 11.01.2014

Nice Work! +rep


Re : Turn on/off the light in the house... - TheSy - 11.01.2014

Thanks!


AW: Turn on/off the light in the house... - NaS - 11.01.2014

Good idea for a script, never saw this anywhere I think .

Tho, you can change this:

Код:
new Text:Player_lights[MAX_PLAYERS];
to this:

Код:
new Text:Player_lights;
and change the rest of the code appropiately, ofc.

Since there are not 500 textdraws needed (if we assume that MAX_PLAYERS is 500), if every textdraw is the same, this is a waste of 499 textdraws.
You can show one textdraw to many players.


Re : Turn on/off the light in the house... - TheSy - 11.01.2014

Thanks.

I give good base code that works perfectly, it is true that the level of optimization is not the top, but it's no big deal either, users wishing to use the script to optimize .


Re: Turn on/off the light in the house... - Naruto_Emilio - 13.01.2014

Woow that gave me an idea! good job!


Re: Turn on/off the light in the house... - Memorex™ - 13.01.2014

Any pics?


Re: Turn on/off the light in the house... - iJumbo - 13.01.2014

good idea


Re: Turn on/off the light in the house... - Don_Cage - 13.01.2014

Hhehehehe,cool idea


Re : Turn on/off the light in the house... - TheSy - 13.01.2014

Sorry I do not have a screenshot handy, if someone wants to make a time if I could possibly add to the thread.

Glad you like it .


Re: Turn on/off the light in the house... - osman2571 - 26.05.2014

(47) : error 017: undefined symbol "Player_lights"


Re: Turn on/off the light in the house... - thaKing - 26.05.2014

It would be very nice, if you put some screens.

And.. good job, bro!


Re: Turn on/off the light in the house... - iRaiDeN - 26.05.2014

Nice...


Re: Turn on/off the light in the house... - osman2571 - 26.05.2014

(47) : error 017: undefined symbol "Player_lights" HELP !!!!!!! ANYBODY


Re: Turn on/off the light in the house... - punklord - 26.05.2014

Great idea!-


Re: Turn on/off the light in the house... - osman2571 - 26.05.2014

undefined symbol "Player_lights" HELP


Re: Turn on/off the light in the house... - TheSy - 26.05.2014

This is a global variable:

pawn Код:
new Text:Player_lights[MAX_PLAYERS];