PDA

View Full Version : How do i get rid of these warnings?!?


Chrillzen
17/08/2010, 08:25 AM
Hi i'm trying to make a FS, but i keep getting these Warnings, how can i get rid of them?

C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(143) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(143) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(158) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(158) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(173) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(173) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(187) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(187) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(194) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(194) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(201) : warning 202: number of arguments does not match definition
C:\Users\Chrillzen\Desktop\Allt\SAMP\filterscripts \S-Cheats.pwn(201) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


12 Warnings.

This is from one warning.

format(string, sizeof(string), "%s, you recieved armor, health and money.", GetPlayerName(playerid));
SendClientMessage(playerid, COLOR_GREEN, string);

ikey07
17/08/2010, 08:38 AM
new name[MAX_PLAYER_NAME];

GetPlayerName(playerid,name,sizeof(name));

format(string, sizeof(string), "%s, you recieved armor, health and money.",name);
SendClientMessage(playerid, COLOR_GREEN, string);

Chrillzen
17/08/2010, 08:45 AM
Ohh thanks!
XD

EDIT: It does not get the playername, it just sais ,you recived..

ikey07
17/08/2010, 08:55 AM
mhmh, strange

Claude
17/08/2010, 10:26 AM
stock GetPlayerName(playerid)
{
new name[20]; // max player name allowed
GetPlayerName(playerid, name, 20);
return name;
}
If you use "GetPlayerName"

Mike Garber
17/08/2010, 10:29 AM
stock GetPlayerName(playerid)
{
new name[20]; // max player name allowed
GetPlayerName(playerid, name, 20);
return name;
}
If you use "GetPlayerName"

Thought GetPlayerName is already defined by default,

Anyways, here's an example of usage;

http://wiki.sa-mp.com/wiki/GetPlayerName

bestr32
18/01/2012, 04:55 PM
new pname[MAX_PLAYER_NAME]; //Defining pname as player's in-game name.
new string[156]; // Defining the string
GetPlayerName(playerid, pname, sizeof(pname)); // Using pname as getting player's name
format(string,sizeof(string), "%s, you received armor, health and money", pname); // Formating the string
SendClientMessage(playerid, COLOUR, string);

milanosie
18/01/2012, 05:47 PM
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s, you recieved armor, health and money.", name));
SendClientMessage(playerid, COLOR_GREEN, string);

RyDeR`
18/01/2012, 05:56 PM
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s, you recieved armor, health and money.", string);
SendClientMessage(playerid, COLOR_GREEN, string);

Gh05t_
18/01/2012, 06:20 PM
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s, you recieved armor, health and money.", string);
SendClientMessage(playerid, COLOR_GREEN, string);


This isn't a proper way as "string" will simply be overwritten. It wouldn't be immediately identified to "call" the variable knowing there has been two possible assignments; the players name, and the formatted string. An example to provide evidence:


main()
{
new integer;
integer = 0;
printf("%d", integer);
integer = 1;
printf("%d", integer);

new string[] = "Hello";
printf("%s",string);
string = "World";
printf("%s",string);
}


Primarily, string would be passed as the last the given assignment (usage of format).


new string[64];
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s, you recieved armor, health and money.", string);
SendClientMessage(playerid, COLOR_GREEN, string);
string = "This is a string.";
printf("%s", string);


There are 3 possible related string assignments, though the one to be outputted is most notably "This is a string."

Basssiiie
18/01/2012, 06:31 PM
This isn't a proper way as "string" will simply be overwritten. It wouldn't be immediately identified to "call" the variable knowing there has been two possible assignments; the players name, and the formatted string.

It should work fine. I use such techniques sometimes to make long lists while only using one string variable. Since 'format' first makes the correct string with the player name and just after the string is made, it's saved into the variable 'string' overwriting the player name. ;) The only thing you have to be aware of, is that the initial length of the variable 'string' is long enough to put the text into. "MAX_PLAYER_NAME" probably isn't long enough, so 'new string[MAX_PLAYER_NAME];' isn't correct, instead use something like 'new string[128];'.

RyDeR`
18/01/2012, 07:20 PM
@Gh05t_, what are you talking about?

Gh05t_
18/01/2012, 07:39 PM
@Gh05t_, what are you talking about?

Just what has been explained in my previous post.


GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s, you recieved armor, health and money.", string);
SendClientMessage(playerid, COLOR_GREEN, string);


Assuming this is what you meant. Isn't proper. Why?


GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s, you recieved armor, health and money.", string);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "%s, you are hungry, go get something to eat.",string);
SendClientMessage(playerid, COLOR_GREEN, string);



Output:
"RyDeR', you have recieved armour, health and money."
"%s, you have recieved armour, health and money.,you are hungry, go get something to eat."

milanosie
18/01/2012, 07:42 PM
where is your string?

SchurmanCQC
18/01/2012, 07:52 PM
new pname[MAX_PLAYER_NAME]; //Defining pname as player's in-game name.
new string[156]; // Defining the string
GetPlayerName(playerid, pname, sizeof(pname)); // Using pname as getting player's name
format(string,sizeof(string), "%s, you received armor, health and money", pname); // Formating the string
SendClientMessage(playerid, COLOUR, string);

You bumped a thread from 2010. Good job, mate.

thimo
18/01/2012, 07:54 PM
WEll i think it is still bugged after 2 years haha

RyDeR`
18/01/2012, 07:55 PM
Well, that's not the case here. It's all about the example in the first page, so don't to teach me what is wrong or correct in this case.

Babul
18/01/2012, 08:37 PM
18/01/2012 - 17/08/2010 == 01/5/0001 == 519 days old topic. happy bday all 8)
edit: i bet this grows upto >10 pages...
help!!!

Gh05t_
18/01/2012, 09:29 PM
Well, that's not the case here. [...] so don't to teach me what is wrong or correct in this case.

Contradiction? You posted an example which I've pointed out was improper (not incorrect, but simply improper) and when confronted regarding the issue, this is your attitude? It seems that you MUST be addressed regarding things when you even make the tiniest of mistakes.