SA-MP Forums Archive
Payday problem - 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: Payday problem (/showthread.php?tid=150568)



Payday problem - bartje01 - 26.05.2010

Hey guys. I've got a little script for a payday.
This is what actualy must happen:

Every 60 seconds now. Will be an hour after it works though.
You will get 1 exp.
After 5 exp you will get +1score.
Then your exp has to set to 0 again too.

This is my script:
Код:
public PayDay()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerInfo[i][Exp] >= 6)
      {
      PlayerInfo[i][Exp] += 1;
      	GameTextForPlayer(i,"PayDay",1000,1);
      	}
      	else
      	{
      	if(PlayerInfo[i][Exp] >= 5)
      	SetPlayerScore(i,GetPlayerScore(i)+1);
      	PlayerInfo[i][Exp] = 0;
      	}
    }
}
}
My problem:
The +1 exp is coming . that is working.
But after I have 5 exp my exp is still growing t0 6 then 7 then 8 then 9 etc.
And I don't get +1 score.
So actualy the only thing that works is that I get +1 exp.
Please somenoe fix it for me.

thanks




Re: Payday problem - Joe_ - 26.05.2010

pawn Код:
public PayDay()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][Exp] != 5)
{
PlayerInfo[i][Exp] += 1;
GameTextForPlayer(i,"PayDay",1000,1);
return 1;
}
SetPlayerScore(i,GetPlayerScore(i)+1);
PlayerInfo[i][Exp] = 0;
}
}
}
}
I don't understand why you were checking if EXP was more or equals 6 when it can never be 6, because when it hits 5, it resets?
Anyway, that code should work.

https://sampwiki.blast.hk/wiki/Control_Structures#Operators


Re: Payday problem - bartje01 - 26.05.2010

Well joe. I want to have it that when the exp is 5 or higher the exp points will reset and the score will be +1.
It is really not working. I tested it.


Re: Payday problem - Joe_ - 26.05.2010

pawn Код:
public PayDay()
{
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][Exp] != 5)
            {
                PlayerInfo[i][Exp] += 1;
                GameTextForPlayer(i,"PayDay",1000,1);
                return 1;
            }
            else
            {
                SetPlayerScore(i,GetPlayerScore(i)+1);
                PlayerInfo[i][Exp] = 0;
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Sorry, I'm not testing, I'm just working off logic in code only lol, so excuse me if it don't work first time.

I am checking if exp does not equal ( != ) 5 and if it doesn't equal 5, exp goes up
otherwise if the does not equal 5 check returns 0 (exp is 5) you will get +1 score and it will reset EXP.



Re: Payday problem - bartje01 - 26.05.2010

Alright I will text it. And you really don't have to appologize that you didn't test it.
You are taking time for me to make this and I really think that is just great.
I'll post if it works.


Re: Payday problem - bartje01 - 26.05.2010

Still doesn't work.


Re: Payday problem - Joe_ - 26.05.2010

I don't know, if you still have the problem I will help you tomorrow, I'm off now lol, sorry.


Re: Payday problem - bartje01 - 26.05.2010

haha ok :PO no problem mate. Thanks for helping