/buybiz - I am avaliable 2 buy only Biz witg 1 ID -
NoDi522 - 26.04.2016
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 = 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);
}
}
else return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.");
}
return 1;
}
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
povargek - 26.04.2016
You can debug this command.
And what happens when you attepmt buy a company not id 1?
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
NoDi522 - 26.04.2016
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
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
povargek - 26.04.2016
Код:
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]))
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
NoDi522 - 26.04.2016
I tried to do that but it still doesn't work
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
N0FeaR - 26.04.2016
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 = 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);
}
}
else return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Ne nalazite se pokraj firme dostupne na kupnju ili vec posjedujete firmu.");
return 1;
}
return 1;
}
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
povargek - 26.04.2016
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.");
}
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
Konstantinos - 26.04.2016
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 = 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;
}
Re: /buybiz - I am avaliable 2 buy only Biz witg 1 ID -
NoDi522 - 26.04.2016
Thank you konstantinos,nofear and povargek for your help and advices.