Compiler Error
#1

hi guys i'am working on a math question system , when i try to compile it i got this error:
F:\...\FREEROAM.pwn(44811) : error 033: array must be indexed (variable "MathAnswer")
F:\...\FREEROAM.pwn(44819) : error 033: array must be indexed (variable "MathAnswer")

-----

CODE:

new rand = randomEx(1,2);
new string[128];
new num1 = randomEx(1,999);
new num2 = randomEx(1,999);
if(rand == 1)
{
MathAnswer = num1+num2;
format(string,sizeof(string),"{a0ef9d}Math Question : %d+%d = ?",num1,num2);
SendClientMessageToAll(RED,string);
}

if(rand == 2)
{ --| Same as rand == 1 , but * instead of + |-- }
and ...
Reply
#2

guys i need to compile it now please help me !
Reply
#3

show us define of MathAnswer i mean the line you defined the mathanswer var
Reply
#4

i fixed that yeah it was about the define , but now i got error on this :


(LINE 12284) if(strcmp(MathAnswer, text, true, 10))
{
-- if someone entered the math answer server respond to him --
}

here is the error :
F:\...\FREEROAM.pwn(12284) : error 035: argument type mismatch (argument 1)
Reply
#5

Quote:
Originally Posted by PoniStar
View Post
i fixed that yeah it was about the define , but now i got error on this :


(LINE 12284) if(strcmp(MathAnswer, text, false, 14) == 0)
{
-- if someone entered the math answer server respond to him --
}

here is the error :
F:\...\FREEROAM.pwn(12284) : error 035: argument type mismatch (argument 1)
it should be like this


PHP Code:
(LINE 12284) if(!strcmp(MathAnswertextfalse))
    {
        -- if 
someone entered the math answer server respond to him --
        }
// and make sure you defined the matchanswer as string 
new MathAnswer[64]; 
Reply
#6

when i define it to string i got this errors again :
F:\...\FREEROAM.pwn(44811) : error 033: array must be indexed (variable "MathAnswer")
F:\...\FREEROAM.pwn(44819) : error 033: array must be indexed (variable "MathAnswer")

:/
Reply
#7

Quote:
Originally Posted by PoniStar
View Post
when i define it to string i got this errors again :
F:\...\FREEROAM.pwn(44811) : error 033: array must be indexed (variable "MathAnswer")
F:\...\FREEROAM.pwn(44819) : error 033: array must be indexed (variable "MathAnswer")

:/
well dude you cant add int in string like this

Code:
MathAnswer = num1+num2;
you have to convert int to string before storing it

too converting number to string use this
PHP Code:
stock FIX_valstr(dest[], valuebool:pack false)
{
    
// format can't handle cellmin properly
    
static const cellmin_value[] = !"-2147483648";
 
    if (
value == cellmin)
        
pack && strpack(destcellmin_value12) || strunpack(destcellmin_value12);
    else
        
format(dest12"%d"value), pack && strpack(destdest12);
}
#define valstr FIX_valstr 
or for easy use you can just to this

PHP Code:
// remove the string and make the matchanswer as int vale 
new MathAnswer;
//and in checking player text do this 
(LINE 12284) if(strcmp(MathAnswertexttrue10))
{
-- if 
someone entered the math answer server respond to him --
}
// change this line to something like this 
if(strval(text) == MatchAnswer
{
-- if 
someone entered the math answer server respond to him --

if you compiler dosent have defined the strval here is simple strval defination

PHP Code:
stock strval(const string[])
{
new 
bool:minusvalueindexmultiplier 1output[25];
if(
string[0] == 45minus true;                 // Checking, if there is a "-" character.
if(!minus && !IsNumericChar(string[0])) return 0;
if(
minus && !IsNumericChar(string[1])) return 0;
GetNumericPartOfString(stringoutputindex);      // Getting the numeric string part.
for(new ii<strlen(output) - 1i++) multiplier *= 10;
for(new 
ii<strlen(output); i++, multiplier /= 10value += (output[i] - 48) * multiplier// Making a number from it...
return minus ? -value value// Returning the final value. If there was "-" character at the begin of string, it will return -value.

or maybe if you want use it as string as stays you can do something like this

PHP Code:
new MathAnswer[64];
new 
string1[64];
new 
sum;
sum num1+num2;
format(string1,sizeof(string1),"%d",sum);
strcpy(MathAnswer,string1); 
Reply
#8

thnx its worked can i have your email or telegram id i am a little newbie and need someones help
Reply
#9

Quote:
Originally Posted by PoniStar
View Post
thnx its worked can i have your email or telegram id i am a little newbie and need someones help
RaMiN#8297 discord

@Ra_Hamelot Telegram

Khramin78 Gmail

Dont forget to rep if i helped you <3

btw this forum is best way to get helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)