28.04.2013, 12:41
My code; OnGameModeInit.
How it looks in-game:
How it should look like:
pawn Код:
public OnGameModeInit()
{
new biztext[128];
new string[128];
DisableInteriorEnterExits();
if (!strcmp("Yes", GAMEMODE_USE_VERSION, true)) { format(string, sizeof(string), "%s - %s", GAMEMODE,VERSION); SetGameModeText(string); }
else { SetGameModeText(GAMEMODE); }
format(MessageString, sizeof(string), "hostname %s", SERVER_NAME);
SendRconCommand(string);
format(MessageString, sizeof(string), "mapname %s", MAP_NAME);
SendRconCommand(string);
format(MessageString, sizeof(string), "weburl %s", WEBSITE);
SendRconCommand(string);
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
for(new idx = 1; idx < sizeof(BusinessInfo); idx++)//Creates a loop, that goes through all of the businesses.
{
format(string, sizeof(string), BPATH, idx);//formats the file path, with the biz ID
INI_ParseFile(string, "loadbiz_%s", .bExtra = true, .extra = idx );//This is very hard to explain, but it basically loads the info from the file(More in ****** y_ini tutorial.)
BusinessInfo[idx][bOutsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[idx][bEntranceX], BusinessInfo[idx][bEntranceY], BusinessInfo[idx][bEntranceZ], BusinessInfo[idx][bWorld]); //Creates a pickup at the business entrance.
switch(BusinessInfo[idx][bType])
{
case 1: biztext = "Bar";
case 2: biztext = "Restaurant";
case 3: biztext = "Phone Company";
case 4: biztext = "24/7";
}
if(BusinessInfo[idx][On_Sell] == 1)
{
format(string,sizeof(string),""COLORGREEN"Owner: None\nPrice: %d\nBusiness type: %s", BusinessInfo[idx][bPrice], biztext);
BusinessInfo[idx][DLabel] = CreateDynamic3DTextLabel(string, 0xFFFFFF, BusinessInfo[idx][bEntranceX],BusinessInfo[idx][bEntranceY],BusinessInfo[idx][bEntranceZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10);
}
else if(BusinessInfo[idx][On_Sell] == 0)
{
format(string,sizeof(string),"Owner: %s\nPrice: %d\nBusiness type: %s",BusinessInfo[idx][bOwner], BusinessInfo[idx][bPrice], biztext);
BusinessInfo[idx][DLabel] = CreateDynamic3DTextLabel(string, 0xFFFFFF, BusinessInfo[idx][bEntranceX],BusinessInfo[idx][bEntranceY],BusinessInfo[idx][bEntranceZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10);
}
}
return 1;
}
How it looks in-game:
How it should look like: