Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnGameModeInit()
- {
- LoadHouses();
- return 1;
- }
- /*---------------------------------------------------------------------------------*/
- forward LoadHouses();
- public LoadHouses()
- {
- printf("Chargement des maisons...");
- mysql_tquery(dbhandle, "SELECT * FROM `server_houses` ORDER BY Hid ASC", "DataLoadHouses", "");
- return 1;
- }
- /*---------------------------------------------------------------------------------*/
- forward DataLoadHouses();
- public DataLoadHouses()
- {
- new rows,
- fields,
- string[144];
- cache_get_data(rows, fields);
- if(rows)
- {
- for(new iSlot, count_nb = cache_get_row_count(); iSlot < count_nb; iSlot++)
- {
- if(iSlot >= sizeof(HouseInfo))
- return 1;
- HouseInfo[iSlot][h_ID] = cache_get_field_content_int(iSlot, "id");
- new houset[64];
- cache_get_field_content(iSlot, "adresse", houset);
- format(HouseInfo[iSlot][h_Adresse], 64, "%s", houset);
- HouseInfo[iSlot][h_PosX] = cache_get_field_content_float(iSlot, "posx");
- HouseInfo[iSlot][h_PosY] = cache_get_field_content_float(iSlot, "posy");
- HouseInfo[iSlot][h_PosZ] = cache_get_field_content_float(iSlot, "posz");
- HouseInfo[iSlot][h_PosA] = cache_get_field_content_float(iSlot, "posa");
- HouseInfo[iSlot][h_OutInt] = cache_get_field_content_int(iSlot, "outint");
- HouseInfo[iSlot][h_OutWorld] = cache_get_field_content_int(iSlot, "outworld");
- /*
- HouseInfo[iSlot][h_InX] = cache_get_field_content_float(iSlot, "InX");
- HouseInfo[iSlot][h_InY] = cache_get_field_content_float(iSlot, "InY");
- HouseInfo[iSlot][h_InZ] = cache_get_field_content_float(iSlot, "InZ");
- */
- HouseInfo[iSlot][h_CP] = CreatePickup(1272, 1, HouseInfo[iSlot][h_PosX], HouseInfo[iSlot][h_PosY], HouseInfo[iSlot][h_PosZ], HouseInfo[iSlot][h_OutWorld]);
- HouseInfo[iSlot][h_Label] = CreateDynamic3DTextLabel(HouseInfo[iSlot][h_Adresse], -1, HouseInfo[iSlot][h_PosX], HouseInfo[iSlot][h_PosY], HouseInfo[iSlot][h_PosZ]+1.0, 2.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, HouseInfo[iSlot][h_OutWorld]);
- UpdateHouseLabel(iSlot);
- }
- }
- return 1;
- }
- /*---------------------------------------------------------------------------------*/
- stock UpdateHouseLabel(houseid)
- {
- new string[256];
- format(string, sizeof(string), "{FFFFFF}%s", HouseInfo[houseid][h_Adresse]);
- UpdateDynamic3DTextLabelText(HouseInfo[houseid][h_Label], -1, string);
- return 1;
- }
- /*---------------------------------------------------------------------------------*/
- forward ADDHOUSE(playerid, i, nom[]);
- public ADDHOUSE(playerid, i, nom[])
- {
- new string[144];
- HouseInfo[i][h_ID] = cache_insert_id();
- strmid(HouseInfo[i][h_Adresse], nom, 0, strlen(nom), 64);
- CreatePickup(1272, 1, HouseInfo[i][h_PosX], HouseInfo[i][h_PosY], HouseInfo[i][h_PosZ], -1);
- format(string, sizeof(string), "[ADMIN] Vous avez crée une nouvelle maison avec l'adresse \"%s\" (ID SQL %d).", HouseInfo[i][h_Adresse], HouseInfo[i][h_ID]);
- SendClientMessage(playerid, COLOR_ADMIN, string);
- return 1;
- }
- /*---------------------------------------------------------------------------------*/
- CMD:creermaison(playerid, params[])
- {
- new nom[128], query[700], Float:x, Float:y, Float:z, Float:a;
- GetPlayerFacingAngle(playerid, a);
- GetPlayerPos(playerid, x, y, z);
- if(sscanf(params, "s[144]", nom))
- {
- return SendClientMessage(playerid, COLOR_SAMP, "Usage: /creermaison [adresse]");
- }
- for(new i = 0; i < sizeof(HouseInfo); i++)
- {
- if(HouseInfo[i][h_ID] == 0)
- {
- mysql_format(dbhandle, query,sizeof(query),"INSERT INTO `server_houses` (adresse, posx, posy, posz, posa) VALUES ('%e', '%0.4f', '%0.4f', '%0.4f', '%0.4f')", nom, x, y, z, a);
- mysql_tquery(dbhandle, query, "ADDHOUSE", "iis", playerid, i, nom);
- return 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement