[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
#2

Good. +rep
Reply
#3

Thanks.
Reply
#4

good job very neat 2 reps.
Reply
#5

Nice Work! +rep
Reply
#6

Thanks!
Reply
#7

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

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

Woow that gave me an idea! good job!
Reply
#10

Any pics?
Reply
#11

good idea
Reply
#12

Hhehehehe,cool idea
Reply
#13

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

(47) : error 017: undefined symbol "Player_lights"
Reply
#15

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

And.. good job, bro!
Reply
#16

Nice...
Reply
#17

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

Great idea!-
Reply
#19

undefined symbol "Player_lights" HELP
Reply
#20

This is a global variable:

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


Forum Jump:


Users browsing this thread: 1 Guest(s)