SA-MP Forums Archive
What Am I doing wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What Am I doing wrong? (/showthread.php?tid=79702)



What Am I doing wrong? - Puzi - 30.05.2009

Код:
 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



Re: What Am I doing wrong? - Think - 30.05.2009

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


Re: What Am I doing wrong? - Puzi - 30.05.2009

Код:
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!)


Re: What Am I doing wrong? - Think - 30.05.2009

where did you put new string[128];


Re: What Am I doing wrong? - Puzi - 30.05.2009

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;
	}



Re: What Am I doing wrong? - Puzi - 30.05.2009

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


Re: What Am I doing wrong? - member - 30.05.2009

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.


Re: What Am I doing wrong? - Puzi - 30.05.2009

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.



Re: What Am I doing wrong? - Puzi - 30.05.2009

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