What Am I doing wrong?
#1

Код:
 if(strcmp(cmdtext, "/needtaxi", true) == 0) {
	   new pname[MAX_PLAYER_NAME];
     GetPlayerName(playerid, pname, sizeof (pname));
     format(string, sizeof(string), " %s potrzebuje Taxi", pname);
     SendClientMessage(playerid, COLOR_GREEN, string); //
  return 1;}
  
 else if(strcmp(cmdtext, "/wtaxi", true) == 0) {
	 new pname[MAX_PLAYER_NAME];
     GetPlayerName(playerid, pname, sizeof (pname));
     format(string, sizeof(string), " %s nie potrzebuje juz Taxi", pname);
     SendClientMessage(playerid, COLOR_GREEN, string); //
  return 1;}
  
else if(strcmp(cmd, "/taxi", true) == 0) {
	 new pname[MAX_PLAYER_NAME];
     GetPlayerName(playerid, pname, sizeof (pname));
     format(string, sizeof(string), " %s jest taksowkarzem. Jak chcesz go uzyc wpisz /needtaxi", pname);
     SendClientMessage(playerid, COLOR_GREEN, string); //
  return 1;}
...I get those errors:

Код:
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1907) : error 017: undefined symbol "string"
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1907) : error 017: undefined symbol "string"
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1907) : error 029: invalid expression, assumed zero
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1907) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
What Am I Doing Wrong? I had same problem with another script saying error 017: undefined symbol ''idx''. And I'm confused because I can't find any information. I tried also on SA-MP Wiki. Help would be appreciated if possible.

Oh and btw, here is the line that might be wrong:

Код:
     format(string, sizeof(string), " %s potrzebuje Taxi", pname);
Thanks and Regards
Puzi
Reply
#2

add this to the commands: new string[128]; or udner onplayercommandtext
Reply
#3

Код:
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1831) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
No errors, but is that bad? Just wondering...

//edit: (100th Post!)
Reply
#4

where did you put new string[128];
Reply
#5

Quote:
Originally Posted by Pandabeer1337
where did you put new string[128];
Under OnPlayerCommandText:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[128];
new idx;

	if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
	{
	  if(!cmdtext[3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE/UŻYCIE: /me [action/akcja]");
	  new string[128], name[16];
	  GetPlayerName(playerid, name, sizeof(name));
	  format(string, 128, "*** %s %s", name, cmdtext[4]);
	  SendClientMessageToAll(COLOR_LIGHTGREEN, string);
	  return 1;
	}
Reply
#6

Any suggestions?...
I guess it maybe all wrong. I created this command so idk tbh.
Reply
#7

double post!

Depends on how most your commands are. If most of your commands are like this:
i.e. it has new string somewhere in the command...
pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
      if(!cmdtext[3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE/UŻYCIE: /me [action/akcja]");
      new string[128], name[16]; // new "string" here!!!
      GetPlayerName(playerid, name, sizeof(name));
      format(string, 128, "*** %s %s", name, cmdtext[4]);
      SendClientMessageToAll(COLOR_LIGHTGREEN, string);
      return 1;
    }
..then remove the new string under OnPlayerCommandText.

If not, then delete new string from that command. The error message is saying that you have two strings named "string" at the same time.
Reply
#8

Quote:
Originally Posted by [B2K
Hustler ]
double post!

Depends on how most your commands are. If most of your commands are like this:
i.e. it has new string somewhere in the command...
pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
      if(!cmdtext[3]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE/UŻYCIE: /me [action/akcja]");
      new string[128], name[16]; // new "string" here!!!
      GetPlayerName(playerid, name, sizeof(name));
      format(string, 128, "*** %s %s", name, cmdtext[4]);
      SendClientMessageToAll(COLOR_LIGHTGREEN, string);
      return 1;
    }
..then remove the new string under OnPlayerCommandText.

If not, then delete new string from that command. The error message is saying that you have two strings named "string" at the same time.
I did that, the warning is gone, but there is a problem in game, as those commands I have made are not shown to everyone. They are only shown to the person that types them. I have tried writing SendClientMessageToAll instead of SendClientMessage but this is what i get:

Код:
C:\DOCUME~1\KAMIL\Pulpit\RPGTDM~1\RPG.pwn(1946) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#9

Sorry if i double posted again but I have a question. Could it be the 'else if' bit that differs from first command? I did that because that was explained on a Polish Pawno site
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)