How to resolve this? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to resolve this? (
/showthread.php?tid=574802)
How to resolve this? -
baba1234 - 20.05.2015
So Ive made an /buy command which only works on certain spots where I declared it.. But this is the problem when I come to that certain spot and type /buy it pops me the dialog and it sends client message That I am not close to the shop but when I go away from that spot and type /buy it sends me 4 client messages that I am not in the spot. I created dynamic system like this.
Код:
#define MAX_DUCANI 4 //how many stores I have
#define DIALOG_DUCAN 14 //the dialog for the store
new Text3D:DucaniText[MAX_DUCANI];
enum ducaninfo { Float:bPosX, Float:bPosY, Float:bPosZ } These are my store coridnates
new Float:DucanInfo[MAX_DUCANI][ducaninfo] =
{
{1470.0087000,-1042.8914000,23.8281000},
{1732.8887000,-1862.6531000,13.5760000},
{1463.3605000,-1666.0052000,14.0469000},
{2460.2310000,-1667.4617000,13.4782000}
};
//MY load
stock LoadDucani() {
for(new t=0;t<MAX_DUCANI;t++) {
DucaniText[t] = Create3DTextLabel(""COL_ZLATNA"Trafika\n__________________\n"COL_BIJELA"Za kupnju kucaj /kupi"COL_ZLATNA"", -1, DucanInfo[t][bPosX], DucanInfo[t][bPosY], DucanInfo[t][bPosZ], 10.0, 0, 0);
}
return 1;
}
LoadDucani();
//This is the Buy command
if(!strcmp(cmdtext, "/kupi"))
{
for(new t=0;t<MAX_DUCANI;t++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, DucanInfo[t][bPosX], DucanInfo[t][bPosY], DucanInfo[t][bPosZ]))
{
ShowPlayerDialog(playerid, DIALOG_DUCAN, DIALOG_STYLE_LIST, "Balkan Godfather-"COL_ZLATNA"Trafika", "Bonovi(10$,20$,50$,100$,200$)\nBuket cvijeca(20$)\nKondom(16$)\nCigare(17$)\nUpaljac(10$)\nCola(8$)\nGusti sok(10$)", "Kupi", "Odustani");
}else
{
SendClientMessage(playerid,COLOR_GREY,"Moras biti u ducanu ili na trafici!");
}
}
return 1;
}
So problem is in this OnPlayerCommand.. And by the way how can I set someone Flowers in the hand when he buys it I did it like this
Код:
if(listitem == 1)
{
if(GetPlayerMoney(playerid)>20)
{
GivePlayerMoney(playerid, -20);
SetPlayerArmedWeapon(playerid,325);
SendClientMessage(playerid, COLOR_YELLOW, "Kupio si buket cvijeca.");
}else
{
SendClientMessage(playerid, COLOR_RED, "Nemas dovoljno novca!");
}
}
But It doesnt works..
Re: How to resolve this? -
Konstantinos - 20.05.2015
You can only be in range with 1 so you won't be for the other three. Sending the message that is not in range inside the loop isn't good.
PHP код:
new bool: in_range;
for(new t=0;t<MAX_DUCANI;t++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, DucanInfo[t][bPosX], DucanInfo[t][bPosY], DucanInfo[t][bPosZ]))
{
in_range = true;
ShowPlayerDialog(playerid, DIALOG_DUCAN, DIALOG_STYLE_LIST, "Balkan Godfather-"COL_ZLATNA"Trafika", "Bonovi(10$,20$,50$,100$,200$)\nBuket cvijeca(20$)\nKondom(16$)\nCigare(17$)\nUpaljac(10$)\nCola(8$)\nGusti sok(10$)", "Kupi", "Odustani");
break;
}
}
if (!in_range) SendClientMessage(playerid,COLOR_GREY,"Moras biti u ducanu ili na trafici!");
Re: How to resolve this? -
baba1234 - 20.05.2015
Yea I know it isnt good but I didnt found another way to do it ty anyways.