Drop Help
#1

The object wont be created, as u see i added printf and won't show up the printf("test2");, hope u guys will be able to help me out

PHP код:
    else if(strcmp(choice,"pot",true) == 0)
    {
        if(
PlayerInfo[playerid][pPot] > 0)
        {
            
format(stringsizeof(string), "You have dropped %d grams of pot."PlayerInfo[playerid][pPot]);
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
            
PlayerPlaySound(playerid10520.00.00.0);
            
format(stringsizeof(string), "* %s has thrown away their pot."GetPlayerNameEx(playerid));
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            new 
amount2 0amounto PlayerInfo[playerid][pPot];
            
PlayerInfo[playerid][pPot] = 0;
            
GetPlayerPos(playerid,X,Y,Z);
            
printf("test");
               for(new 
0sizeof(DropInfo); i++)
              {
                  if(
strcmp(GetPlayerNameEx(playerid), DropInfo[i][dpOwner], true) == 0)
                  {
                      
amount2++;
                  }
              }
            if(
amount2 <= 2)
               {
               for(new 
0sizeof(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), 0strlen(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(1578XYZ-10.00.00.0GetPlayerVirtualWorld(playerid));
                       return 
1;
                       }
                  }
              }
        }
        else
        {
            
SendClientMessageEx(playeridCOLOR_GREY"You are not carrying any pot to throw away!");
        }
    } 
Reply
#2

have you checked the value of "amount2"?

Код:
printf("amount2 has %d", amount2);
before if(amount2 <= 2) would be nice..
The code looks fine although on the first glance, so maybe the simpliest answer could be right on this one
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
have you checked the value of "amount2"?

Код:
printf("amount2 has %d", amount2);
before if(amount2 <= 2) would be nice..
The code looks fine although on the first glance, so maybe the simpliest answer could be right on this one
Should i paste that with test2?
Reply
#4

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Should i paste that with test2?
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
Reply
#5

Quote:
Originally Posted by Sascha
Посмотреть сообщение
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
Ok, i be back soon and tell you the result!

EDIT

this show in the console

Код:
[10:58:42] test
[10:58:42] amount2 has 500
Reply
#6

Ok then it's obvious that "test2" is not shown
Код:
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; 
                       } 
                  } 
              }
On this you check if "amount2" has avalue lower or equally than/to "2". As the value is 500, it is higher than 2 and therefor the code in the if condition is going to be ignored.
Код:
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
				}
would be a solution for the server to do something in the case of a value higher than 2.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)