Try Command errors
#1

Hi there guys, sorry for my bad english, but I'm having some errors and warnings in the /try system that i make. I wanted a /try system, I didn't find nothing in the internet about it so I decide to invent and do my own system using random, so the logic is, if random = 0, the try is successful, but if random = 1, isn't successful, so the try fails.
I guess the logic is good but the code as some errors that i can't detect, if any of you could help me with the errors and the warnings i would be apreciate.
Code:

Код HTML:
CMD:tentar(playerid, params[]) // [PT] tentar = [EN] try
{
    static string[144], text[120], name[MAX_PLAYER_NAME], Float: pX, Float: pY, Float: pZ;
    GetPlayerName(playerid, name, sizeof(name));

    if(sscanf(params, "s[120]", text)) return SendClientMessage(playerid, cinzento, "Usa /tentar [Aзгo]"); // [EN]Usa /try [Action]
	new value = random(1); // so that's how I make my teory
    format(string, sizeof(string), "%s tenta %s", name, text); // Formating the message
    GetPlayerPos(playerid, pX, pY, pZ);

    foreach(new i: Player)
    {
        if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
		{
        if value="0"
		{
            SendClientMessage(i, roxo, string, "e consegue*");
		}
        if value="1"
		{
            SendClientMessage(i, roxo, string, "e falha*"); // roxo = purple, " e falha " = " and fails " 
        }
        
        }

}
return 1;
}
Errors:

PHP код:
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(46) : warning 211possibly unintended assignment
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(47) : error 029invalid expressionassumed zero
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(48) : warning 202number of arguments does not match definition
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(50) : warning 211possibly unintended assignment
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(51) : error 029invalid expressionassumed zero
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(52) : warning 202number of arguments does not match definition
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(58) : warning 217loose indentation
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(51) : warning 204symbol is assigned a value that is never used"value" 
Reply
#2

Change if value="0" to:
pawn Код:
if(value == 0)
And same goes for the other one too.
Reply
#3

П would also recommend to use 'switch'
pawn Код:
CMD:tentar(playerid, params[]) // [PT] tentar = [EN] try
{
    static string[144], text[120], name[MAX_PLAYER_NAME], Float: pX, Float: pY, Float: pZ;
    GetPlayerName(playerid, name, sizeof(name));

    if(sscanf(params, "s[120]", text)) return SendClientMessage(playerid, cinzento, "Usa /tentar [Aзгo]"); // [EN]Usa /try [Action]
    new value = random(1); // so that's how I make my teory
    format(string, sizeof(string), "%s tenta %s", name, text); // Formating the message
    GetPlayerPos(playerid, pX, pY, pZ);

    foreach(new i: Player)
    {
        if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
        {
            switch(value)
            {
                case 0:
                {
                    SendClientMessage(i, roxo, string, "e consegue*");
                }
                case 1:
                {
                    SendClientMessage(i, roxo, string, "e falha*"); // roxo = purple, " e falha " = " and fails "
                }
            }
        }
    }
    return 1;
}
Reply
#4

@Don_Cage I try it that way but when I was tested didn't say the result, something like this:
*Jack_Simpson tenta saltar o muro = [EN] *Jack_Simpson trys to jump the wall
It should be like
*Jack_Simpson tenta saltar o muro e falha/consegue = [EN] *Jack_Simpson trys to jump the wall and do it/fail ( sorry for the bad english)

@Faisal_khan

Thank you, i didn't know yet how to work with random values, it helped, but still have some errors:

Quote:

entar(playerid, params[]) // [PT] tentar = [EN] try
{
static string[144], text[120], name[MAX_PLAYER_NAME], Float: pX, Float: pY, Float: pZ;
GetPlayerName(playerid, name, sizeof(name));

if(sscanf(params, "s[120]", text)) return SendClientMessage(playerid, cinzento, "Usa /tentar [Aзгo]"); // [EN]Usa /try [Action]
new value = random(1); // so that's how I make my teory
format(string, sizeof(string), "%s tenta %s", name, text); // Formating the message
GetPlayerPos(playerid, pX, pY, pZ);

foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
{
if value == 0
{
SendClientMessage(i, roxo, string, "e consegue*");
}
if value == 1
{
SendClientMessage(i, roxo, string, "e falha*"); // roxo = purple, " e falha " = " and fails "
}

}

}
return 1;
}

Errors:

Quote:

C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(47) : error 029: invalid expression, assumed zero
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(4 : warning 202: number of arguments does not match definition
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(51) : error 029: invalid expression, assumed zero
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(52) : warning 202: number of arguments does not match definition
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(5 : warning 217: loose indentation

Reply
#5

You did 'if value == 0'
you must do if(value == 0)
Reply
#6

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
You did 'if value == 0'
you must do if(value == 0)
I make that and the script compiles, with some warnings, but it doesn't work, doesn't say if did the try or not.
The warnings are:

PHP код:
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(48) : warning 202number of arguments does not match definition
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(52) : warning 202number of arguments does not match definition
C
:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(58) : warning 217loose indentation 
Reply
#7

So i look into Faisal's script and i tryied in a differente way, but when I try, it's always sucessful

Quote:

CMD:tentar(playerid, params[])
{
static string[144], text[120], name[MAX_PLAYER_NAME], Float: pX, Float: pY, Float: pZ;
GetPlayerName(playerid, name, sizeof(name));

if(sscanf(params, "s[120]", text)) return SendClientMessage(playerid, cinzento, "Usa /tentar [Aзгo]");
new value = random(1);
GetPlayerPos(playerid, pX, pY, pZ);

foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
{
switch(value)
{
case 0:
{
format(string, sizeof(string), "%s tenta %s e consegue*", name, text);
SendClientMessage(i, roxo, string);
}
case 1:
{
format(string, sizeof(string), "%s tenta %s e falha*", name, text);
SendClientMessage(i, roxo, string);
}
}
}
}
return 1;
}

Reply
#8

Anyone could give a hand ? I can't put this working :c
Reply
#9

https://sampwiki.blast.hk/wiki/Random
If you use random(1);
It will never give you 1, so use random(2);
Reply
#10

It works! Thank you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)