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

PHP код:
// /BUYBIZ
CMD:kupifirmu(playerid,params[])
{
    new 
poruka[999],string[128],name[128];
    
GetPlayerName(playerid,name,128);
    
    if(!
IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste se spojili na server");
    if(
pUlogiran[playerid] != 1) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
     for(new 
BizID 1BizID MAX_FIRMABizID++)
    {
        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.");
            else if(
FirmaInfo[BizID][fOwned] == 0)
            {
                
PlayerInfo[playerid][pNovac] -= FirmaInfo[BizID][fCijena];
                
GivePlayerMoney(playerid,-FirmaInfo[BizID][fCijena]);
                
PlayerInfo[playerid][pFirmaID] = BizID;
                
                
FirmaInfo[BizID][fOwned] = 1;
                
FirmaInfo[BizID][fOwner] = name;
                
FirmaInfo[BizID][fZakljucana] = 0;
                
format(string,128,"Firma %s",FirmaTip(BizID));
                
strmid(FirmaInfo[BizID][fIme],string,0,strlen(string),255);
                
                
format(poruka,999,"{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,512,"{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
                
new datoteka[128];
                
format(datoteka,128,FirmaPATH,BizID);
                new 
INI:File INI_Open(datoteka);
                
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);
            }
        }
        else return 
SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.");
    }
    return 
1;

Reply
#2

You can debug this command.
And what happens when you attepmt buy a company not id 1?
Reply
#3

I get the "error" message -
PHP код:
you are not near biz doors 
In this case that is:
PHP код:
SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu."); 
And yes, i'm at the location of biz ent
Reply
#4

Код:
if(IsPlayerInRangeOfPoint(playerid,1.0,FirmaInfo[BizID][fUlazX],FirmaInfo[BizID][fUlazY],FirmaInfo[BizID][fUlazZ]))
Maybe "1.0" very small, you can try replace:

Код:
if(IsPlayerInRangeOfPoint(playerid,5.0,FirmaInfo[BizID][fUlazX],FirmaInfo[BizID][fUlazY],FirmaInfo[BizID][fUlazZ]))
Reply
#5

I tried to do that but it still doesn't work
Reply
#6

Try this

PHP код:
CMD:kupifirmu(playerid,params[])
{
    new 
poruka[999],string[128],name[128];
    
GetPlayerName(playerid,name,128);

    if(!
IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste se spojili na server");
    if(
pUlogiran[playerid] != 1) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
    for(new 
BizID 1BizID MAX_FIRMABizID++)
    {
        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.");
            else if(
FirmaInfo[BizID][fOwned] == 0)
            {
                
PlayerInfo[playerid][pNovac] -= FirmaInfo[BizID][fCijena];
                
GivePlayerMoney(playerid,-FirmaInfo[BizID][fCijena]);
                
PlayerInfo[playerid][pFirmaID] = BizID;

                
FirmaInfo[BizID][fOwned] = 1;
                
FirmaInfo[BizID][fOwner] = name;
                
FirmaInfo[BizID][fZakljucana] = 0;
                
format(string,128,"Firma %s",FirmaTip(BizID));
                
strmid(FirmaInfo[BizID][fIme],string,0,strlen(string),255);

                
format(poruka,999,"{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,512,"{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
                
new datoteka[128];
                
format(datoteka,128,FirmaPATH,BizID);
                new 
INI:File INI_Open(datoteka);
                
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);
            }
        }
        else return 
SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.");
        return 
1;
    }
    return 
1;

Reply
#7

I'm find the bug. Try this:

Код:
CMD:kupifirmu(playerid,params[]) 
{ 
    new poruka[999],string[128],name[128]; 
    GetPlayerName(playerid,name,128); 
     
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste se spojili na server"); 
    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."); 
            else if(FirmaInfo[BizID][fOwned] == 0) 
            { 
                PlayerInfo[playerid][pNovac] -= FirmaInfo[BizID][fCijena]; 
                GivePlayerMoney(playerid,-FirmaInfo[BizID][fCijena]); 
                PlayerInfo[playerid][pFirmaID] = BizID; 
                 
                FirmaInfo[BizID][fOwned] = 1; 
                FirmaInfo[BizID][fOwner] = name; 
                FirmaInfo[BizID][fZakljucana] = 0; 
                format(string,128,"Firma %s",FirmaTip(BizID)); 
                strmid(FirmaInfo[BizID][fIme],string,0,strlen(string),255); 
                 
                format(poruka,999,"{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,512,"{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 
                new datoteka[128]; 
                format(datoteka,128,FirmaPATH,BizID); 
                new INI:File = INI_Open(datoteka); 
                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 SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.");  
}
Reply
#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
#9

Thank you konstantinos,nofear and povargek for your help and advices.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)