Random calculate
#1

Hi,

i have a big problem with a random arithmetical problem.

I create 3 variables:

Код:
new rechenzahl1 = 0;
new rechenzahl2 = 0;
new rechenergebnis = 0;
Then a timer is invoked every eight minutes.

Код:
rechenzahl1 = random(101);
rechenzahl2 = random(101);
new str[256];
new zufall = random(2);
switch(zufall)
{
	case 0:
	{
		rechenergebnis = rechenzahl1+rechenzahl2;
		format(str,sizeof(str),"[RECHNEN]: Bla bla '{969696}%d+%d{00FF78}' in bla bla bla",rechenzahl1,rechenzahl2);
		SendClientMessageToAll(0x00FF78FF,str);
	}
	case 1:
	{
		rechenergebnis = rechenzahl1-rechenzahl2;
		format(str,sizeof(str),"[RECHNEN]: Bla bla '{969696}%d-%d{00FF78}' in bla bla bla",rechenzahl1,rechenzahl2);
		SendClientMessageToAll(0x00FF78FF,str);
	}
}
In OnPlayerText

Код:
if(!strcmp(text, rechenergebnis, false))
{
        if(Reaktion == 2) 
        {
              GewinntReaktion(playerid);
        }
        return 1;
}
(rechenergebnis is the computational results)

And now the errors/warnings:

(5449) : error 035: argument type mismatch (argument 2) //Line: if(!strcmp(text, rechenergebnis, false))
(17981) : warning 204: symbol is assigned a value that is never used: "rechenergebnis"

I hope you understand my problem
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "rechenergebnis", true) != -1)
    {
         if(Reaktion == 2)
         {
             GewinntReaktion(playerid);
             return 1;
         }    
    }    
}
Reply
#3

Ok, first error is "away"
But the second warnig is also there (17981) : warning 204: symbol is assigned a value that is never used: "rechenergebnis"
Reply
#4

Can you show me that part? full part of that code
Reply
#5

It is this:

Код:
rechenzahl1 = random(101);
rechenzahl2 = random(101);
new str[256];
new zufall = random(2);
switch(zufall)
{
	case 0:
	{
		rechenergebnis = rechenzahl1+rechenzahl2;
		format(str,sizeof(str),"[RECHNEN]: Bla bla '{969696}%d+%d{00FF78}' in bla bla bla",rechenzahl1,rechenzahl2);
		SendClientMessageToAll(0x00FF78FF,str);
	}
	case 1:
	{
		rechenergebnis = rechenzahl1-rechenzahl2;
		format(str,sizeof(str),"[RECHNEN]: Bla bla '{969696}%d-%d{00FF78}' in bla bla bla",rechenzahl1,rechenzahl2);
		SendClientMessageToAll(0x00FF78FF,str);
	}
}
In top of the script:

new rechenzahl1 = 0;
new rechenzahl2 = 0;
new rechenergebnis = 0;
Reply
#6

Hm.. can't find the problem, i guess you should do like this
On top you got

pawn Код:
new rechenergebnis = 0;
make it

pawn Код:
new rechenergebnis
Reply
#7

Ok, thank you I try some things out and if it not work i will write it here.

Offtopic: How to use the Pawncode? I cant find it here. And what means +REP?
Reply
#8

As Rudy_ has no idea of what he is talking about, let me help you out here. 'rechenergebnis' is an integer value (that is, a number).

strcmp (meaning STRing CoMPare) compares two strings. Seeing as rechenergebnis is no string, it cannot compare it.

So: either you have to change rechenergebnis to a string at the check or translate the text to a value.
pawn Код:
// solution 1: changing rechenergebnis to a string at OnPlayerText:
public OnPlayerText(playerid, text[])
{
    new rechenergebnisString[10]; // it wouldnt be really large anyway
    format(rechenergebnisString, sizeof(rechenergebnisString), "%d", rechenergebnis);
    if(!strcmp(text, rechenergebnisString, true))
    {
         if(Reaktion == 2) // not a clue what this does though?
         {
             GewinntReaktion(playerid);
             return 1;
         }    
    }    
}
pawn Код:
// Solution 2: translating the text to an integer
public OnPlayerText(playerid, text[])
{
    if(strval(text) == rechenergebnis)
    {
         if(Reaktion == 2)
         {
             GewinntReaktion(playerid);
             return 1;
         }    
    }    
}
To your second question: [pawn][/pawn] and to your third: +REP is just reputation whoring and can be ignored
Reply
#9

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)