This code don't send money
#1

Hello,i've this lotto code to sent the jackpot money at the winner,i made some tests in my server and when i pickup the winning number,it shows the winning message but IT DOESN'T GIVE MONEY

pawn Код:
if(winner != -1) //If there was a winner
    {
      for(new i; i<MAX_PLAYERS; i++) //checks through all players
    {
        new Pname[24];
        GetPlayerName(i, Pname, 24);
        new str[128];
        SendClientMessageToAll(0x62FF32FF, "****LOTTO INFORMATION****"); //Lotto info
        format(str, sizeof(str), "WE HAVE A WINNER! %s (Id: %d) won $%d!!!!", Pname, i, Jackpot);
        LottoLog(str);
        GivePlayerMoney(i, Jackpot);
        SendClientMessageToAll(0x62FF32FF, str); //Lotto info
        SendClientMessageToAll(0x62FF32FF, "Make sure you get a ticket for next draw - /lotto [1-30]"); //Lotto info
        Jackpot = LOTTO_START; //Resets the jackpot
    }
    }
What's wrong?
Reply
#2

Right Code:

Код:
if(strcmp(cmd, "/givemoney", true) == 0)
	{
		new string[128];
		new playermoney;
		new sendername[MAX_PLAYER_NAME];
		new giveplayer[MAX_PLAYER_NAME];
 		new giveplayerid, moneys;
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>");
			return 1;
		}
		moneys = strval(tmp);

		if (IsPlayerConnected(giveplayerid) && giveplayerid != INVALID_PLAYER_ID && giveplayerid != playerid)
		{
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			playermoney = GetPlayerMoney(playerid);

			if (moneys > 0 && playermoney >= moneys)
			{
				GivePlayerMoney(playerid, (0 - moneys));
				GivePlayerMoney(giveplayerid, moneys);
				format(string, sizeof(string), "You gave %s(%d), Money Amount: $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_GREEN, string);
				format(string, sizeof(string), "You got $%d from %s(%d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_GREEN, string);
				PlayerPlaySound(playerid,1084,0.0,0.0,0.0);
				printf("%s(%d) has transfered %d to %s(%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
				}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "Invalid amount!");
			}
		}
		else
		{
			format(string, sizeof(string), "ERROR: Player Is Not Connected or Its Yourself!");
			SendClientMessage(playerid, COLOR_RED, string);
		}
		return 1;
	}
Reply
#3

Sorry For Touble Posting But i got that you want /givemoney CODE
Sorry for Code btw!
Reply
#4

Emh what is that?I've already my givemoney cmd,i need only to fix that part of code i provided in first post.
Reply
#5

Debug the code, print out something after every line. It must be silently exiting somewhere.
Reply
#6

Lol check other FilterScript i remember i have seen Jackpot FS
Reply
#7

like i find : http://forum.sa-mp.com/showthread.ph...hlight=JackPot

USE NEXT TIME SEARCH!
(You can take there a Code)
Reply
#8

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Debug the code, print out something after every line. It must be silently exiting somewhere.
pawn Код:
GivePlayerMoney(i, Jackpot);
Is not enough? The lotto system works good,the numbers are draw'ed but the only fault is it don't give the jackpot money to the winner.

Quote:
Originally Posted by James Coral
Посмотреть сообщение
like i find : http://forum.sa-mp.com/showthread.ph...hlight=JackPot

USE NEXT TIME SEARCH!
(You can take there a Code)
Before i made this topic i searched like 5 times.I've coded ALL lotto script and in my gamemode I dont use (and i dont want) others filterscripts,i make my functions so if i have a problem i know where is the fix.
Reply
#9

Quote:
Originally Posted by James Coral
Посмотреть сообщение
like i find : http://forum.sa-mp.com/showthread.ph...hlight=JackPot

USE NEXT TIME SEARCH!
(You can take there a Code)
This isn't helpful. They want to script it theirselves, rather than become a plagiarist.

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
pawn Код:
GivePlayerMoney(i, Jackpot);
Is not enough? The lotto system works good,the numbers are draw'ed but the only fault is it don't give the jackpot money to the winner.
It should be. Print out what "i" and "Jackpot" are. And, like I say, try printing out every line to see if it's silently exerting.
Reply
#10

Oh sorry for not explaining.

The "i" is a loop of all players:

pawn Код:
for(new i; i<MAX_PLAYERS; i++)
    {
the "Jackpot" is a value that store the Jackpot money and gives it to the winner.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)