PDA

View Full Version : warning 204: symbol is assigned a value that is never used


MrAjusshi
10/07/2017, 02:34 AM
I have this warning after compiled my script.


warning 202: number of arguments does not match definition
warning 204: symbol is assigned a value that is never used: "maskid"

stock MaskedName(_id)
{
new sender[MAX_PLAYER_NAME];
new maskid = minrand(10000,99999);
if(PlayerTemp[_id][hname]) myStrcpy(sender, "Stranger-%d", maskid);
else myStrcpy(sender, RPName(_id));
return sender;
}

Barnwell
10/07/2017, 04:31 AM
Use else if, and add else

MrAjusshi
10/07/2017, 07:06 AM
What do you mean by "else if and add else"

Tass007
11/07/2017, 11:08 AM
It seems that you've set the whole script up incorrectly.

With this line here,

if(PlayerTemp[_id][hname]) myStrcpy(sender, "Stranger-%d", maskid);

When you come out of the brackets, you're finishing your if statement. Therefore anything after that is just gibberish. But it's not giving you any errors in terms of that because it's in a language that the compiler can understand. Also that if statement is empty, because you're not comparing it to anything. It'll give you an error once you've fixed the one you're currently having. When using an if statement you're normally asking the compiler something. For example.

I might ask how the weather is. Two answers could be sunny or raining. So therefore the if statement would be
if(weather == sunny)
{
do....
}
else if(weather == raining)
{
do something else...
}

Whenever you're asking something (or creating an if statement) there has to be a "do" something after it. Otherwise it's completely pointless. You're asking the compiler IF the weather is sunny but you're not telling it what to do after the compiler figures out that the weather is sunny. So a more understanding piece of code I suppose would be like this.

if(weather == sunny)
{
SendClientMessageToAll(RED, "[WEATHER UPDATE]: The weather is sunny! Enjoy the beautiful sunshine!");
}
else if(weather == raining)
{
SendClientMessageToAll(RED, "[WEATHER UPDATE]: The weather is raining! Please drive carefully!");
}

I hope that explains to you why you're having the issue you're having. Since in your if statement you are firstly not comparing it to anything you're merely just saying:

if(weather)

You aren't asking anything or comparing anything. As I don't know how your script is set out or anything like that I'm going to guess and show you how it should hopefully work.

Also a piece of advise, don't use the word 'stock' in front of the function as it isn't good coding practice.
Read this link for more.
http://forum.sa-mp.com/showthread.php?t=570635

Back to your code.

MaskedName(playerid)//There doesn't need to be the word 'stock' in front of the function.
{
new sender[MAX_PLAYER_NAME];
new maskid = minrand(10000,99999);
if(PlayerTemp[playerid][hname] == 1)//Asking the compiler if PlayerTemp hname is equal to one (I'm guessing hname is if the player has hidden their name)
{
myStrcpy(sender, "Stranger-%d", maskid);//It'll display Stranger and the maskid that was randomized in line 4.
}
else if(PlayerTemp[playerid][hname] == 0)//If the player doesn't have their name hidden
{
myStrcpy(sender, RPName(playerid));//It'll display the players Roleplay name.
}
return sender;
}

I hope this helps you. If you have anymore questions don't hesitate to ask.

MrAjusshi
13/07/2017, 02:57 AM
It's still not changing anything. Still shows warning and it didn't work in game. I mean it;s like :

Stranger- says: Hi!
but it should be
Stranger-23912 says: Hi!

Tass007
13/07/2017, 03:15 AM
It's showing the maskid because you put it there.
myStrcpy(sender, "Stranger-%d", maskid);

Just remove the -%d and remove everything in the script related to maskid

That'll get rid of your warning

MrAjusshi
14/07/2017, 05:51 AM
But the problem is, if I remove them the stranger ID that I needed will not be available. And It's really hard to detect that person.

Meller
14/07/2017, 06:01 AM
stock MaskedName(_id)
{
new sender[MAX_PLAYER_NAME];
if(PlayerTemp[_id][hname]) {
new maskid = minrand(10000, 99999);
myStrcpy(sender, "Stranger-%d", maskid);
}
else myStrcpy(sender, RPName(_id));
return sender;
}

MrAjusshi
14/07/2017, 10:43 AM
Guys, please understand it very well.

The problem is with this
warning 202: number of arguments does not match definition
warning 204: symbol is assigned a value that is never used: "maskid"

K0P
14/07/2017, 12:03 PM
Where are you using the var 'maskid'?

raydx
14/07/2017, 12:29 PM
Warning lines ID or we cannot help.

MrAjusshi
15/07/2017, 01:17 AM
Where are you using the var 'maskid'?

Top of the script.

Jefff
15/07/2017, 02:14 AM
You cant use %d in strcmp cmon guys

stock MaskedName(_id)
{
new sender[MAX_PLAYER_NAME];
if(PlayerTemp[_id][hname])
{
new maskid = minrand(10000,99999);
valstr(sender,maskid);
strins(sender,"Stranger-",0);
}
else myStrcpy(sender, RPName(_id));

return sender;
}