11.01.2014, 11:09
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:
Under the variable added:
In OnGameModeInit:
For my part I do the action off/turn on the light in a single order, you way later to do as you wish.
If you have any problems with the script, do not hesitate to ask about it here or by private courier.
TheSy.
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];
pawn Код:
#define MAX_HOUSE 100
pawn Код:
enum House_informations
{
House_Lights
};
new House_Infos[MAX_HOUSE][House_informations];
pawn Код:
forward House_update(i);
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);
}
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;
}
TheSy.