String and number compare.
#1

Hi. How to compare String and number? i have variable like this:

Code:
new NUMBER;
How to check if player text is same like this variable? I mean OnPlayerText.

I try:

Code:
if(!strcmp(text,NUMBER,true))
{
But i get errors.
Reply
#2

Try this:

pawn Code:
new szVal[12];
valstr(szVal, NUMBER);
if(!strcmp(text, szVal, true))
{
    ...
}
Reply
#3

pawn Code:
new a[20],b;
if(strval(a) == b)
{
}
Reply
#4

Thanks. Now why i get crashed when i do this:

Top in my gamemode:

Code:
new REACTIONTEST = 0;
Code:
new randomnumber1 = random( 100 );
new randomnumber2 = random( 100 );

REACTIONTEST = randomnumber1+randomnumber2;
Reply
#5

it must be something else. this doesn't crash.
pawn Code:
public OnFilterScriptInit()
{
   new REACTIONTEST,randomnumber1 = random( 100 ),randomnumber2 = random( 100 );
   REACTIONTEST = randomnumber1+randomnumber2;
   printf(#%d, REACTIONTEST);
}
Reply
#6

It's not crash, it's like i can't write any command. And it not always: here when it's bad:

Code:
0+17
When is 0 then it happin. Maybe 0 i can't use?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)