else if(strcmp(choice,"pot",true) == 0)
{
if(PlayerInfo[playerid][pPot] > 0)
{
format(string, sizeof(string), "You have dropped %d grams of pot.", PlayerInfo[playerid][pPot]);
SendClientMessageEx(playerid, COLOR_WHITE, string);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "* %s has thrown away their pot.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
new amount2 = 0, amounto = PlayerInfo[playerid][pPot];
PlayerInfo[playerid][pPot] = 0;
GetPlayerPos(playerid,X,Y,Z);
printf("test");
for(new i = 0; i < sizeof(DropInfo); i++)
{
if(strcmp(GetPlayerNameEx(playerid), DropInfo[i][dpOwner], true) == 0)
{
amount2++;
}
}
if(amount2 <= 2)
{
for(new i = 0; i < sizeof(DropInfo); i++)
{
printf("test2");
if(DropInfo[i][dpX] == 0.0 && DropInfo[i][dpY] == 0.0 && DropInfo[i][dpZ] == 0.0)
{
strmid(DropInfo[i][dpOwner], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), 255);
DropInfo[i][dpAmmo] = amounto;
DropInfo[i][dpX] = X;
DropInfo[i][dpY] = Y;
DropInfo[i][dpZ] = Z;
DropInfo[i][dpWorld] = GetPlayerVirtualWorld(playerid);
DropInfo[i][dpType] = 2;
DropInfo[i][dpObject] = CreateDynamicObject(1578, X, Y, Z-1, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid));
return 1;
}
}
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "You are not carrying any pot to throw away!");
}
}
printf("amount2 has %d", amount2);
have you checked the value of "amount2"?
![]() Код:
printf("amount2 has %d", amount2); The code looks fine although on the first glance, so maybe the simpliest answer could be right on this one |
no.
You shall check that before you start your condition... you check if amount2 <= 2 the server should print the value into the console before that, so you'll know the amount. If I'm right and the amount is > 2, then test2 will not be called |
[10:58:42] test [10:58:42] amount2 has 500
if(amount2 <= 2) { for(new i = 0; i < sizeof(DropInfo); i++) { printf("test2"); if(DropInfo[i][dpX] == 0.0 && DropInfo[i][dpY] == 0.0 && DropInfo[i][dpZ] == 0.0) { strmid(DropInfo[i][dpOwner], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), 255); DropInfo[i][dpAmmo] = amounto; DropInfo[i][dpX] = X; DropInfo[i][dpY] = Y; DropInfo[i][dpZ] = Z; DropInfo[i][dpWorld] = GetPlayerVirtualWorld(playerid); DropInfo[i][dpType] = 2; DropInfo[i][dpObject] = CreateDynamicObject(1578, X, Y, Z-1, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid)); return 1; } } }
if(amount2 <= 2) { for(new i = 0; i < sizeof(DropInfo); i++) { printf("test2"); if(DropInfo[i][dpX] == 0.0 && DropInfo[i][dpY] == 0.0 && DropInfo[i][dpZ] == 0.0) { strmid(DropInfo[i][dpOwner], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), 255); DropInfo[i][dpAmmo] = amounto; DropInfo[i][dpX] = X; DropInfo[i][dpY] = Y; DropInfo[i][dpZ] = Z; DropInfo[i][dpWorld] = GetPlayerVirtualWorld(playerid); DropInfo[i][dpType] = 2; DropInfo[i][dpObject] = CreateDynamicObject(1578, X, Y, Z-1, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid)); return 1; } } } else { printf("test3, amount is higher than 2, as it's %d", amount2); //some other code if you want }