SA-MP Forums Archive
Help with code - 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: Help with code (/showthread.php?tid=617597)



Help with code - ,TomY' - 23.09.2016

Hi. I have code:

Code:
		for(new Bussines; Bussines < MAX_BUSSINES; Bussines ++)
	{
		if(Bussinesinf[Bussines][Buyed])
		{
			Bussinesinf[Bussines][Profit] += Bussinesinf[Bussines][Earning];
		}
	}
This code will add Profit for Bussines. Also I done timer. This code adding for all bussines profit. Now I want to do, that this code will add profit only for connected ( online ) bussines owners. How to do that?

Bussines owner:
Code:
Bussinesinf[Bussines][Owner]



Re: Help with code - ,TomY' - 23.09.2016

Still need help :/


Re: Help with code - Shinja - 23.09.2016

if Bussinesinf[Bussines][Owner] is a string that stores player name
PHP Code:
new ownerid;
for(new 
BussinesBussines MAX_BUSSINESBussines ++)
    {
        if(
Bussinesinf[Bussines][Buyed])
        {
                    
sscanf(Bussinesinf[Bussines][Owner], "r"ownerid);
                    if(
ownerid != INVALID_PLAYER_ID)
                   {
                       
Bussinesinf[Bussines][Profit] += Bussinesinf[Bussines][Earning];
                   }
        }
    } 



Re: Help with code - Dutheil - 23.09.2016

Quote:
Originally Posted by Shinja
View Post
if Bussinesinf[Bussines][Owner] is a string that stores player name
PHP Code:
new ownerid;
for(new 
BussinesBussines MAX_BUSSINESBussines ++)
    {
        if(
Bussinesinf[Bussines][Buyed])
        {
                    new 
owneridsscanf(Bussinesinf[Bussines][Owner], "r"ownerid);
                    if(
ownerid != INVALID_PLAYER_ID)
                   {
                       
Bussinesinf[Bussines][Profit] += Bussinesinf[Bussines][Earning];
                   }
        }
    } 
You declare two times ownerid, there is a problem.


Re: Help with code - Shinja - 23.09.2016

Quote:
Originally Posted by Dutheil
View Post
You declare two times ownerid, there is a problem.
Owh just a typo because i copied it later, thanks for reminding me