Dice -
JordanDoughty - 31.08.2014
Ok,
Player 1 has offered you to bet $1,000
Player 2 has accepted the bet
Player 2 Rolls a dice.
Player 1 Rolls a dice.
Nothing Happens
------------------
Player 2 has offered you to bet $1,000
Player 1 has accepted the bet
Player 1 Rolls a dice.
Player 2 Rolls a dice.
They win/lose.
Why?
http://pastebin.com/dQMWa6fA
Re: Dice -
JordanDoughty - 31.08.2014
Quote:
Originally Posted by ******
pawn Код:
iMoney2 = pBetAmount[iTarget],
"iTarget" is not set.
|
It is set?
pawn Код:
new iTarget,
szPlayerName[MAX_PLAYER_NAME],
szPlayerName2[MAX_PLAYER_NAME],
szString[256],
iMoney = pBetAmount[playerid],
iMoney2 = pBetAmount[iTarget],
Re: Dice -
JordanDoughty - 31.08.2014
Quote:
Originally Posted by ******
pawn Код:
iMoney2 = pBetAmount[iTarget],
"iTarget" is not set.
|
Also, When I /diceroll the text comes up twice for me saying i roll'ed and so does the /acceptdice text if I am ID 0.
Re: Dice -
JordanDoughty - 31.08.2014
anyone? :S
Re: Dice -
SKAzini - 31.08.2014
In /dicebet and /acceptdice, iTarget is not set properly as ****** said. It's always 0, you see?
Re: Dice -
JordanDoughty - 31.08.2014
Quote:
Originally Posted by SKAzini
In /dicebet and /acceptdice, iTarget is not set properly as ****** said. It's always 0, you see?
|
How do I fix this?
Re: Dice -
Abagail - 31.08.2014
Example using sscanf,
pawn Код:
if(sscanf(params, "u", iTarget)) return SendClientMessage(playerid, -1, "SYNTAX: /dicebet [player]");
You never set, or actually define the iTarget variable.
Re: Dice -
JordanDoughty - 31.08.2014
Quote:
Originally Posted by Abagail
Example using sscanf,
pawn Код:
if(sscanf(params, "u", iTarget)) return SendClientMessage(playerid, -1, "SYNTAX: /dicebet [player]");
You never set, or actually define the iTarget variable.
|
has helped me but I get this:
[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at index 65535 past array upper bound 499
[debug] AMX backtrace:
[debug] #0 00008264 in public cmd_diceroll (0x00000000, 0x00008450) from Untitle
d.amx
[debug] #1 native CallLocalFunction () [00472fc0] from samp-server.exe
[debug] #2 00000464 in public OnPlayerCommandText (0x00000000, 0x0000842

from
Untitled.amx
What does this mean
Re: Dice -
JordanDoughty - 31.08.2014
pawn Код:
CMD:diceroll(playerid, params[])
{
new iTarget = pDiceBetID[playerid];
new iTargetDice = iTarget;
if(pDiceBetID[playerid] == iTarget && pDiceBetID[iTarget] == playerid && pDiceBetAmount[playerid] == pDiceBetAmount[iTarget])
{
new szString[128],
//szString2[128],
szPlayerName[MAX_PLAYER_NAME],
iMoney;
new dice = random(6)+1;
GetPlayerName(playerid, szPlayerName, sizeof(szPlayerName));
format(szString, sizeof(szString), "* %s rolls a dice that lands on %d.",szPlayerName,dice);
SendClientMessage(playerid, -1, szString);
SendClientMessage(iTargetDice, -1, szString);
Highest[playerid] = dice;
if(Highest[playerid] > Highest[iTargetDice])
{
format(szString, sizeof(szString), "You have lost $%i to %s this was taken from you.", pDiceBetAmount[iTargetDice], szPlayerName);
SendClientMessage(iTargetDice, -1, szString);
format(szString, sizeof(szString), "You have won $%i from %s you have been given this.",pDiceBetAmount[playerid],iTargetDice);
SendClientMessage(playerid, -1, szString);
GivePlayerMoney(iTargetDice, -pDiceBetAmount[iTargetDice]);
GivePlayerMoney(playerid, pDiceBetAmount[playerid]);
}
else if(Highest[iTargetDice] > Highest[playerid])
{
format(szString, sizeof(szString), "You have lost $%i to %s this was taken from you.", pDiceBetAmount[playerid], iTargetDice);
SendClientMessage(playerid, -1, szString);
format(szString, sizeof(szString), "You have won $%i from %s you have been given this.",pDiceBetAmount[iTargetDice], szPlayerName);
SendClientMessage(iTargetDice, -1, szString);
GivePlayerMoney(iTargetDice, pDiceBetAmount[iTargetDice]);
GivePlayerMoney(playerid, -pDiceBetAmount[playerid]);
}
}
else return SendClientMessage(playerid, -1, "No one has offered you a dicebet!");
return 1;
}
Thats the code
Re: Dice -
JordanDoughty - 31.08.2014
Quote:
Originally Posted by JordanDoughty
pawn Код:
CMD:diceroll(playerid, params[]) { new iTarget = pDiceBetID[playerid]; new iTargetDice = iTarget; if(pDiceBetID[playerid] == iTarget && pDiceBetID[iTarget] == playerid && pDiceBetAmount[playerid] == pDiceBetAmount[iTarget]) { new szString[128], //szString2[128], szPlayerName[MAX_PLAYER_NAME], iMoney; new dice = random(6)+1; GetPlayerName(playerid, szPlayerName, sizeof(szPlayerName)); format(szString, sizeof(szString), "* %s rolls a dice that lands on %d.",szPlayerName,dice); SendClientMessage(playerid, -1, szString); SendClientMessage(iTargetDice, -1, szString); Highest[playerid] = dice; if(Highest[playerid] > Highest[iTargetDice]) { format(szString, sizeof(szString), "You have lost $%i to %s this was taken from you.", pDiceBetAmount[iTargetDice], szPlayerName); SendClientMessage(iTargetDice, -1, szString); format(szString, sizeof(szString), "You have won $%i from %s you have been given this.",pDiceBetAmount[playerid],iTargetDice); SendClientMessage(playerid, -1, szString); GivePlayerMoney(iTargetDice, -pDiceBetAmount[iTargetDice]); GivePlayerMoney(playerid, pDiceBetAmount[playerid]); } else if(Highest[iTargetDice] > Highest[playerid]) { format(szString, sizeof(szString), "You have lost $%i to %s this was taken from you.", pDiceBetAmount[playerid], iTargetDice); SendClientMessage(playerid, -1, szString); format(szString, sizeof(szString), "You have won $%i from %s you have been given this.",pDiceBetAmount[iTargetDice], szPlayerName); SendClientMessage(iTargetDice, -1, szString); GivePlayerMoney(iTargetDice, pDiceBetAmount[iTargetDice]); GivePlayerMoney(playerid, -pDiceBetAmount[playerid]); } } else return SendClientMessage(playerid, -1, "No one has offered you a dicebet!"); return 1; }
Thats the code
|
Debugged the code and this line is the cause:
pawn Код:
if(pDiceBetID[playerid] == iTarget && pDiceBetID[iTarget] == playerid && pDiceBetAmount[playerid] == pDiceBetAmount[iTarget] && IsPlayerConnected(iTarget))