[FilterScript] Turn on/off the light in the house...
#1

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.
Reply


Messages In This Thread
Turn on/off the light in the house... - by TheSy - 11.01.2014, 11:09
Re: Turn on/off the light in the house... - by ViciousRoleplay123 - 11.01.2014, 17:30
Re : Turn on/off the light in the house... - by TheSy - 11.01.2014, 17:31
Re: Turn on/off the light in the house... - by Yves - 11.01.2014, 19:15
Re: Turn on/off the light in the house... - by KingServerIRAN - 11.01.2014, 19:19
Re : Turn on/off the light in the house... - by TheSy - 11.01.2014, 20:11
AW: Turn on/off the light in the house... - by NaS - 11.01.2014, 20:30
Re : Turn on/off the light in the house... - by TheSy - 11.01.2014, 20:50
Re: Turn on/off the light in the house... - by Naruto_Emilio - 13.01.2014, 21:52
Re: Turn on/off the light in the house... - by Memorex™ - 13.01.2014, 22:22
Re: Turn on/off the light in the house... - by iJumbo - 13.01.2014, 22:33
Re: Turn on/off the light in the house... - by Don_Cage - 13.01.2014, 22:38
Re : Turn on/off the light in the house... - by TheSy - 13.01.2014, 23:03
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 00:14
Re: Turn on/off the light in the house... - by thaKing - 26.05.2014, 04:06
Re: Turn on/off the light in the house... - by iRaiDeN - 26.05.2014, 04:06
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 07:56
Re: Turn on/off the light in the house... - by punklord - 26.05.2014, 08:26
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 09:16
Re: Turn on/off the light in the house... - by TheSy - 26.05.2014, 11:23
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 12:21
Re: Turn on/off the light in the house... - by TheSy - 26.05.2014, 12:25
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 13:38
Re: Turn on/off the light in the house... - by osman2571 - 26.05.2014, 22:15
Re: Turn on/off the light in the house... - by TheSy - 26.05.2014, 22:18
Re: Turn on/off the light in the house... - by satafinix - 26.05.2014, 23:18
Re: Turn on/off the light in the house... - by DemME - 26.05.2014, 23:32

Forum Jump:


Users browsing this thread: 5 Guest(s)