31.03.2009, 17:05
How can i check if the player has given the correct answer in the chat? When i use my onplayertext , i get these errors:
pawn Код:
D:\_Spellen\bkp\filterscripts\dceros.pwn(87) : error 033: array must be indexed (variable "text")
D:\_Spellen\bkp\filterscripts\dceros.pwn(87) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
pawn Код:
#include <a_samp>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define rand(%1,%2) (random(%2 - %1 - 1) + %1 + 1)
#define COLOR_YELLOW 0xFFFF00AA
//***********
new _DC_Guessed;
new _DC_Answer;
//***********
public OnFilterScriptInit()
{
print("Eros's Number Game Loaded");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(acgame, 6, cmdtext);
return 0;
}
dcmd_acgame(playerid, params[])
{
#pragma unused playerid
// Nummer van 10 tot 100
//new NumberRange = strval(params);
new NumberRange = strval(params);
new NUM[9];
printf("NumberRange = %d", NumberRange);
printf("NumberRange - 9 = %d", NumberRange - 9);
NUM[0] = NumberRange - 9; // Het eerste getal
NUM[1] = NumberRange - 8; // Het tweede getal
NUM[2] = NumberRange - 7; // Het derde getal
NUM[3] = NumberRange - 6; // Het vierde getal
NUM[4] = NumberRange - 5; // Het vijfde getal
NUM[5] = NumberRange - 4; // Het zesde getal
NUM[6] = NumberRange - 3; // Het zevende getal
NUM[7] = NumberRange - 2; // Het achtste getal
NUM[8] = NumberRange - 1; // Het negende getal
new RandomRemove;
new RemovedNumber;
RandomRemove = rand(1, 9);
// rand(1, 9);
RemovedNumber = NUM[RandomRemove-1];
printf("Removed Number %d (%d) NOW: %d", RandomRemove, RemovedNumber, NUM[RandomRemove-1]);
// strdel(s1, 4, 10);
new TestString[128];
format(TestString, sizeof(TestString), "%d %d %d %d %d %d %d %d %d\n", NUM[0], NUM[1], NUM[2], NUM[3], NUM[4], NUM[5], NUM[6], NUM[7], NUM[8]);
if (RandomRemove == 1) strdel(TestString, 0, 3);
else if (RandomRemove == 2) strdel(TestString, 3, 6);
else if (RandomRemove == 3) strdel(TestString, 6, 9);
else if (RandomRemove == 4) strdel(TestString, 9, 12);
else if (RandomRemove == 5) strdel(TestString, 12, 15);
else if (RandomRemove == 6) strdel(TestString, 15, 18);
else if (RandomRemove == 7) strdel(TestString, 18, 21);
else if (RandomRemove == 8) strdel(TestString, 21, 24);
else if (RandomRemove == 9) strdel(TestString, 24, 27);
print(TestString);
SendClientMessageToAll(COLOR_YELLOW, "DC Quiz: Which Number Is Missing?");
SendClientMessageToAll(COLOR_YELLOW, TestString);
_DC_Guessed = 0;
_DC_Answer = RandomRemove;
return 1;
}
public OnPlayerText(playerid, text[])
{
new string[128];
new Name[MAX_PLAYER_NAME+1];
if(text == _DC_Answer))
{
if(_DC_Guessed == 0)
{
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "DC Quiz: %s Has Given The Correct Number! Number: %d", Name, _DC_Answer);
SendClientMessageToAll(COLOR_YELLOW, string);
_DC_Guessed = 1;
}
}
return 1;
}