/buybiz - I am avaliable 2 buy only Biz witg 1 ID
#8

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.


pawn Код:
FirmaInfo[BizID][fOwner] = name;
That's not how you copy strings. Use strcpy instead:
pawn Код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif
and use:
pawn Код:
strcpy(FirmaInfo[BizID][fOwner], name, MAX_PLAYER_NAME);
Also 128 for the player's name and another 2 strings (one 999) is kind of ridiculous stuff.

---

PHP код:
CMD:kupifirmu(playerid,params[])
{
    if (
pUlogiran[playerid] != 1) return SendClientMessage(playerid, -1"{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
    for (new 
BizID 1BizID MAX_FIRMABizID++)
    {
        if (
IsPlayerInRangeOfPoint(playerid1.0FirmaInfo[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(playeridnameMAX_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], nameMAX_PLAYER_NAME);
            
FirmaInfo[BizID][fZakljucana] = 0;
            
format(porukasizeof poruka"Firma %s"FirmaTip(BizID));
            
strmid(FirmaInfo[BizID][fIme], poruka0strlen(poruka), 255);
            
format(poruka128"{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), BizIDFirmaInfo[BizID][fCijena]);
            
SendClientMessage(playerid, -1poruka);
            
DestroyDynamic3DTextLabel(FirmaLabel[BizID]);
            
format(porukasizeof 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, -1FirmaInfo[BizID][fUlazX], FirmaInfo[BizID][fUlazY], FirmaInfo[BizID][fUlazZ], 30.0);
            
// SPREMANJE PODATAKA 
            
format(porukasizeof porukaFirmaPATHBizID);
            new 
INIFile 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 
INIpFile 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;

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)