Command only works for a pickup with the ID 1. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command only works for a pickup with the ID 1. (
/showthread.php?tid=197978)
Command only works for a pickup with the ID 1. -
Biesmen - 10.12.2010
Pretty weird problem. For the other commands I use exactly the same method, but somehow it doesn't work for this one.
The command only works for a pickup(business) with the ID: 1.
Here's the code.
pawn Код:
if(strcmp(cmd, "/setentfee", true) == 0)
{
new playernamez[MAX_PLAYER_NAME];
GetPlayerName(playerid, playernamez, sizeof(playernamez));
new file[31];
for(new i; i < sizeof(BusinessData); i++)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /setentfee <entry fee>");
return 1;
}
format(file, sizeof(file), "BusinessData/%i.txt", i + 1);
if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z)) // x y z is already defined.
{
new entryfee;
entryfee = strval(tmp);
if(entryfee < 0 || entryfee > 5000) { return SendClientMessage(playerid, COLOR_RED, "Entry fee cannot be lower than $0 or higher than $5000"); }
if(!strcmp(playernamez, BusinessData[i][BusinessOwner], false))
{
BusinessData[i][EntFee] = entryfee;
dini_IntSet(file, "EntFee", entryfee);
format(string, sizeof(string), "You've set your entry fee to: $%i", entryfee);
SendClientMessage(playerid, NEWBIE_COLOR, string);
break;
}
}
}
}
If you're trying this command at a business with the ID 2 or higher, it will say I didn't enter the 'tmp'.
It will give this message: USAGE: /setentfee <entry fee>
Re: Command only works for a pickup with the ID 1. -
Biesmen - 11.12.2010
Apperently my previous posts got deleted o.O.
I tried return 1;, instead of break, no result.
I also renamed 'entryfee' to something else, it also failed.
I'm using the EXACT method for an other command..
Re: Command only works for a pickup with the ID 1. -
MadeMan - 11.12.2010
pawn Код:
if(strcmp(cmd, "/setentfee", true) == 0)
{
new playernamez[MAX_PLAYER_NAME];
GetPlayerName(playerid, playernamez, sizeof(playernamez));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /setentfee <entry fee>");
return 1;
}
new entryfee = strval(tmp);
if(entryfee < 0 || entryfee > 5000) { return SendClientMessage(playerid, COLOR_RED, "Entry fee cannot be lower than $0 or higher than $5000"); }
new file[31];
for(new i; i < sizeof(BusinessData); i++)
{
format(file, sizeof(file), "BusinessData/%i.txt", i + 1);
if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z)) // x y z is already defined.
{
if(!strcmp(playernamez, BusinessData[i][BusinessOwner], false))
{
BusinessData[i][EntFee] = entryfee;
dini_IntSet(file, "EntFee", entryfee);
format(string, sizeof(string), "You've set your entry fee to: $%i", entryfee);
SendClientMessage(playerid, NEWBIE_COLOR, string);
break;
}
}
}
}