Help here Cash Goes in -ve
#1

pawn Code:
for(new i = 0; i < GetMaxPlayers(); i++)
        {
            for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
            {
                if(IsPlayerConnected(playerid) && spawned[playerid] == 1)
                {
                    pInfo[playerid][DaysAlive] ++;
                    if(pInfo[playerid][DaysAlive] == 1)
                    {
                        if(online != 1)
                        {
                            pInfo[playerid][birthdays] ++;
                            new pmoney, randcash,playername[100];
                            pmoney = GetPlayerMoney(i);
                            GetPlayerName(playerid,playername, sizeof(playername));
                            randcash = random(pmoney);
                            GiveCashToPlayer(playerid,-randcash);
                            GivePlayerMoney(playerid, randcash);
                            SCM(playerid,COLOR_ORANGE,"Happy Birth Day");
                            new str[500],str1[500];
                            format(str,sizeof(str),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$%d",randcash);
                            GameTextForPlayer(playerid,str,5000,3);
                            format(str1,sizeof(str1),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~%s(%d)~N~Sent ~G~$%d",playername,playerid,randcash);
                            GameTextForAllBut(playerid,str1,5000,3);
                            format(string,sizeof(string),"~P~~H~HAPPY BIRH DAY ~W~%s(%d) ~B~~H~is now ~R~~H~%d ~B~~H~years old",playername,playerid,pInfo[playerid][birthdays]);
                            TextDrawSetString(Textdraw222,string);
                            TextDrawShowForAll(Textdraw222);
                            AUTO_SAVE(playerid);
                        }
                                        }
                                }
                        }
                }
GiveCashToPlayer
pawn Code:
forward GiveCashToPlayer(playerid,const money);
public GiveCashToPlayer(playerid,const money)
{
   for(new i = 0; i < MAX_PLAYERS; i ++)
   {
      if(!IsPlayerConnected(i)) continue;
      if(playerid == i) continue;

      GivePlayerMoney(i,money);
   }
}
GameTextForALLBut
pawn Code:
forward GameTextForAllBut(playerid, const text[],time,style);
public GameTextForAllBut(playerid, const text[],time,style)
{
   for(new i = 0; i < MAX_PLAYERS; i ++)
   {
      if(!IsPlayerConnected(i)) continue;
      if(playerid == i) continue;

      GameTextForPlayer(i,text,time,style);
   }
}
TextDrawShowForAllbut
pawn Code:
forward TextDrawShowForAllBut(playerid,const Text:TextDraw);
public TextDrawShowForAllBut(playerid,const Text:TextDraw)
{
   for(new i = 0; i < MAX_PLAYERS; i ++)
   {
      if(!IsPlayerConnected(i)) continue;
      if(playerid == i) continue;

      TextDrawShowForPlayer(i,TextDraw);
   }
}
Now I want that get the amount from every player who is online an random amount from each player so that it may not cause it's -ve money
e.g
An player got $1 it will take random amount from him 1 or 0 not 2-onward
pawn Code:
format(str1,sizeof(str1),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~%s(%d)~N~Sent ~G~$%d",playername,playerid,randcash);
                            GameTextForAllBut(playerid,str1,5000,3);
here randcash should show the amount to each player the amount that he gave
Then the amount we get from all online player give it to player who got birthday
pawn Code:
GivePlayerMoney(playerid, randcash);
format(str,sizeof(str),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$%d",randcash);
                            GameTextForPlayer(playerid,str,5000,3);
here randcash should give him all amount together that we got from online players


Help me here too
https://sampforum.blast.hk/showthread.php?tid=511647
Reply
#2

well i can fix other but idk why instead of adding 1 in days alive it adds random amount mostly 30
Reply
#3

1 for getting all players and 1 for playerid
Reply
#4

Edit: Nevermind not what I thought, sorry.
Reply
#5

number of players online well if there are no other player online he gets unlimited cash
online number of players
Reply
#6

THANKS For help if i get any error i will tell u ralf
Reply
#7

ralf i can't add it like this way so can u
pawn Code:
if(GameHour == 23 && GameMinute == 59)
    {
        for(new i = 0; i < GetMaxPlayers(); i++)
        {
            for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
            {
                if(IsPlayerConnected(playerid) && spawned[playerid] == 1)
                {
                    pInfo[playerid][DaysAlive] ++;
                    if(pInfo[playerid][DaysAlive] == 1)
                    {
                        if(online != 1)
                        {
                            pInfo[playerid][birthdays] ++;

                            new pmoney, randcash,playername[100];
                            new oldcash,newcash;
                            oldcash = GetPlayerMoney(i);
                            pmoney = GetPlayerMoney(i);
                            GetPlayerName(playerid,playername, sizeof(playername));
                            randcash = random(pmoney/2);
                            GiveCashToPlayer(i,-randcash);
                            GivePlayerMoney(playerid, randcash);
                            newcash = oldcash - GetPlayerMoney(i);
                            SCM(playerid,COLOR_ORANGE,"Happy Birth Day");
                            new str[500],str1[500];
                            format(str,sizeof(str),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$%d",randcash);
                            GameTextForPlayer(playerid,str,5000,3);
                            format(str1,sizeof(str1),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~%s(%d)~N~Sent ~G~$%d",playername,playerid,newcash);
                            GameTextForAllBut(playerid,str1,5000,3);
                            format(string,sizeof(string),"~P~~H~HAPPY BIRH DAY ~W~%s(%d) ~B~~H~is now ~R~~H~%d ~B~~H~years old",playername,playerid,pInfo[playerid][birthdays]);
                            TextDrawSetString(Textdraw222,string);
                            TextDrawShowForAll(Textdraw222);
                            AUTO_SAVE(playerid);
                        }
                        else
                        {
                            pInfo[playerid][birthdays] ++;
                            new playername[100];
                            GetPlayerName(playerid,playername, sizeof(playername));
                            GivePlayerMoney(playerid, 200000);
                            new str[500];
                            format(str,sizeof(str),"Happy Birth Day Recived "GREEN"$200000");
                            SCM(playerid,COLOR_SKYBLUE,str);
                            format(string,sizeof(string),"~P~~H~HAPPY BIRTH DAY ~W~%s(%d) ~B~~H~is now ~R~~H~%d ~B~~H~years old",playername,playerid,pInfo[playerid][birthdays]);
                            TextDrawSetString(Textdraw222,string);
                            TextDrawShowForAll(Textdraw222);
                            GameTextForPlayer(playerid,"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$200000",5000,3);
                            AUTO_SAVE(playerid);
                        }
                    }
                    if(pInfo[playerid][DaysAlive] == 3 && pInfo[playerid][birthdays] == 1)
                    {
                        if(online != 1)
                        {
                            pInfo[playerid][birthdays] ++;
                            new pmoney, randcash,randcash2,playername[100];
                            pmoney = GetPlayerMoney(i);
                            GetPlayerName(playerid,playername, sizeof(playername));
                            randcash = random(pmoney);
                            randcash2 = randcash*2;
                            GiveCashToPlayer(playerid,-randcash);
                            GivePlayerMoney(playerid, randcash2);
                            SCM(playerid,COLOR_ORANGE,"Happy Birth Day");
                            new str[500],str1[500];
                            format(str,sizeof(str),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$%d",randcash2);
                            GameTextForPlayer(playerid,str,5000,3);
                            format(str1,sizeof(str1),"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~%s(%d)~N~Sent ~G~$%d",playername,playerid,randcash);
                            GameTextForAllBut(playerid,str1,5000,3);
                            format(string,sizeof(string),"~P~~H~HAPPY BIRH DAY ~W~%s(%d) ~B~~H~is now ~R~~H~%d ~B~~H~years old",playername,playerid,pInfo[playerid][birthdays]);
                            TextDrawSetString(Textdraw222,string);
                            TextDrawShowForAll(Textdraw222);
                            AUTO_SAVE(playerid);
                        }
                        else
                        {
                            pInfo[playerid][birthdays] ++;
                            new playername[100];
                            GetPlayerName(playerid,playername, sizeof(playername));
                            GivePlayerMoney(playerid, 400000);
                            new str[500];
                            format(str,sizeof(str),"Happy Birth Day Recived "GREEN"$400000");
                            SCM(playerid,COLOR_SKYBLUE,str);
                            format(string,sizeof(string),"~P~~H~HAPPY BIRTH DAY ~W~%s(%d) ~B~~H~is now ~R~~H~%d ~B~~H~years old",playername,playerid,pInfo[playerid][birthdays]);
                            TextDrawSetString(Textdraw222,string);
                            TextDrawShowForAll(Textdraw222);
                            GameTextForPlayer(playerid,"~g~h~Happy ~b~~h~Birth ~P~H~Day~N~~W~Recived ~G~$400000",5000,3);
                            AUTO_SAVE(playerid);
                        }
                    }
                }
            }
        }
    }
Reply
#8

no i mean that was my small code see this full one i can do it but can u make it all in the stock ??
Reply
#9

Quote:
Originally Posted by Ralfie
View Post
Im sorry, i meant that code:

Code:
if(GameHour == 23 && GameMinute == 59)
{
   Bday();
}
man i mean i posted the new code can u please change that into the stock ??
Reply
#10

solved thanks to ralf
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)