26.04.2016, 15:01
You cannot know if you are near any "biz door" if you don't let the loop finish. You use "return" in the loop and it stops. Stop the loop only if a result is found.
Also:
- Checking if the player is connected is totally worthless.
- Indexes in arrays start from 0 so it's a waste not to use it.
That's not how you copy strings. Use strcpy instead:
and use:
Also 128 for the player's name and another 2 strings (one 999) is kind of ridiculous stuff.
---
Also:
- Checking if the player is connected is totally worthless.
- Indexes in arrays start from 0 so it's a waste not to use it.
pawn Код:
FirmaInfo[BizID][fOwner] = name;
pawn Код:
#if !defined strcpy
#define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif
pawn Код:
strcpy(FirmaInfo[BizID][fOwner], name, MAX_PLAYER_NAME);
---
PHP код:
CMD:kupifirmu(playerid,params[])
{
if (pUlogiran[playerid] != 1) return SendClientMessage(playerid, -1, "{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
for (new BizID = 1; BizID < MAX_FIRMA; BizID++)
{
if (IsPlayerInRangeOfPoint(playerid, 1.0, FirmaInfo[BizID][fUlazX], FirmaInfo[BizID][fUlazY], FirmaInfo[BizID][fUlazZ]))
{
if (PlayerInfo[playerid][pNovac] < FirmaInfo[BizID][fCijena]) return SendClientMessage(playerid, -1, "{FF0000}Greska:{FFFFFF} Nemate dovoljno novca na racunu.");
if (PlayerInfo[playerid][pFirmaID] != 0) return SendClientMessage(playerid, -1, "{FF0000}Greska:{FFFFFF} Vec posjedujete firmu.");
if (FirmaInfo[BizID][fOwned] != 0) return SendClientMessage(playerid, -1, "{FF0000}Greska:{FFFFFF} Firma nije dostupna na kupnju.");
new poruka[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
PlayerInfo[playerid][pNovac] -= FirmaInfo[BizID][fCijena];
GivePlayerMoney(playerid, -FirmaInfo[BizID][fCijena]);
PlayerInfo[playerid][pFirmaID] = BizID;
FirmaInfo[BizID][fOwned] = 1;
strcpy(FirmaInfo[BizID][fOwner], name, MAX_PLAYER_NAME);
FirmaInfo[BizID][fZakljucana] = 0;
format(poruka, sizeof poruka, "Firma %s", FirmaTip(BizID));
strmid(FirmaInfo[BizID][fIme], poruka, 0, strlen(poruka), 255);
format(poruka, 128, "{0080FF}WG:{FFFFFF} Kupili ste firmu. Tip:{0080FF} %s. {FFFFFF}ID: {0080FF}%d.{FFFFFF} Cijena:{0080FF} %d${FFFFFF}.\n{0080FF}WG:{FFFFFF} Upravljajte svojom firmom putem komande {0080FF}/firma", FirmaTip(BizID), BizID, FirmaInfo[BizID][fCijena]);
SendClientMessage(playerid, -1, poruka);
DestroyDynamic3DTextLabel(FirmaLabel[BizID]);
format(poruka, sizeof poruka, "{FFFFFF}Ime firme: {0080FF}%s\n{FFFFFF}Adresa: {0080FF}%d\n{FFFFFF}Tip firme: {0080FF}%s\n{FFFFFF}Vlasnik firme: {0080FF}%s\n{FFFFFF}Cijena firme: {0080FF}%d$\n\n{FFFFFF}Za ulazak u firmu pritisnite tipku {0080FF}'f' {FFFFFF}ili {0080FF}'enter'", FirmaInfo[BizID][fIme], FirmaInfo[BizID][fAdresa], FirmaTip(BizID), FirmaInfo[BizID][fOwner], FirmaInfo[BizID][fCijena]);
FirmaLabel[BizID] = CreateDynamic3DTextLabel(poruka, -1, FirmaInfo[BizID][fUlazX], FirmaInfo[BizID][fUlazY], FirmaInfo[BizID][fUlazZ], 30.0);
// SPREMANJE PODATAKA
format(poruka, sizeof poruka, FirmaPATH, BizID);
new INI: File = INI_Open(poruka);
INI_SetTag(File, "Podatci");
INI_WriteInt(File, "Owned", 1);
INI_WriteString(File, "Owner", name);
INI_WriteInt(File, "Zakljucana", 0);
INI_Close(File);
new INI: pFile = INI_Open(UserPath(playerid));
INI_SetTag(pFile, "Podatci");
INI_WriteInt(pFile, "pFirmaID", BizID);
INI_Close(pFile);
return 1;
}
}
SendClientMessage(playerid, -1, "{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.")
return 1;
}