warning 204: symbol is assigned a value that is never used
#1

I have this warning after compiled my script.

pawn Код:
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;
}
Reply
#2

Use else if, and add else
Reply
#3

What do you mean by "else if and add else"
Reply
#4

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.
https://sampforum.blast.hk/showthread.php?tid=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.
Reply
#5

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!
Reply
#6

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
Reply
#7

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.
Reply
#8

PHP код:
stock MaskedName(_id)
{
  new 
sender[MAX_PLAYER_NAME];
  if(
PlayerTemp[_id][hname]) {
     new 
maskid minrand(1000099999);
     
myStrcpy(sender"Stranger-%d"maskid);
  }
  else 
myStrcpy(senderRPName(_id));
  return 
sender;

Reply
#9

Guys, please understand it very well.

The problem is with this
pawn Код:
warning 202: number of arguments does not match definition
warning 204: symbol is assigned a value that is never used: "maskid"
Reply
#10

Where are you using the var 'maskid'?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)