SA-MP Forums Archive
Help pls - 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)
+--- Thread: Help pls (/showthread.php?tid=663851)



Help pls - Ulises212 - 13.02.2019

i'm doing a minigame and I want that when the users execute the command to enter I warn the other users but I miss this error

Код HTML:
C:\Users\PC\Desktop\samp037_svr_R2-1-1_win32\filterscripts\RocketD.pwn(44) : error 029: invalid expression, assumed zero
C:\Users\PC\Desktop\samp037_svr_R2-1-1_win32\filterscripts\RocketD.pwn(44) : error 017: undefined symbol "name"
C:\Users\PC\Desktop\samp037_svr_R2-1-1_win32\filterscripts\RocketD.pwn(44) : warning 215: expression has no effect
C:\Users\PC\Desktop\samp037_svr_R2-1-1_win32\filterscripts\RocketD.pwn(44) : error 001: expected token: ";", but found "]"
C:\Users\PC\Desktop\samp037_svr_R2-1-1_win32\filterscripts\RocketD.pwn(44) : fatal error 107: too many error messages on one line
This is my code

Код HTML:
CMD:rocketd(playerid,params[])
{
 (this is the line of error)new string[128];, name [MAX_PLAYER_NAME];
	 GetPlayerName(playerid, name, sizeof(name));
	 {
	  format(string, 128, "{FFFFFF}%s {FFCC00}has entered the minigame of{FFFF00} [Rocket-Survive] {FFCC00}(/rocketd)", GetPlayerName(playerid));
	  SendClientMessageToAll(-1, string);
                return 1;
}



Re: Help pls - Lokii - 13.02.2019

PHP код:
new string[128], name[MAX_PLAYER_NAME]; 



Re: Help pls - MyUndiesSmell - 13.02.2019

You can use a stock to return a players name, it will be alot faster than typing that out each time.

Код:
CMD:rocketd(playerid, params[])
{
	new string[128];
	format(string, sizeof(string), {FFFFFF}%s {FFCC00}has entered the minigame of{FFFF00} [Rocket-Survive] {FFCC00}(/rocketd)", pName(playerid));
	SendClientMessageToAll(-1, string);
	return 1;
}

stock pName(playerid)
{
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, MAX_PLAYER_NAME);
      return name;
}



Re: Help pls - ComDuck - 13.02.2019

Quote:
Originally Posted by Ulises212
Посмотреть сообщение
Код HTML:
CMD:rocketd(playerid,params[])
{
 (this is the line of error)new string[128];, name [MAX_PLAYER_NAME];
	 GetPlayerName(playerid, name, sizeof(name));
	 {
	  format(string, 128, "{FFFFFF}%s {FFCC00}has entered the minigame of{FFFF00} [Rocket-Survive] {FFCC00}(/rocketd)", GetPlayerName(playerid));
	  SendClientMessageToAll(-1, string);
                return 1;
}
You have an extra unneeded bracket below GetPlayerName. Besides, this is wrong:

Код:
new string[128];, name [MAX_PLAYER_NAME];
The semicolon is there to indicate the end of line for a function, to tell the compiler that this function is complete and must not be mixed up with a different function. The comma is unnecessary, you can remove it. You can rewrite that code as:

Код:
// 1
new string[128], name[MAX_PLAYER_NAME+1];

// 2
new string[128]; new name[MAX_PLAYER_NAME+1];

// 3
new 
        string[128],
        name[MAX_PLAYER_NAME+1];

// and probably other variances of the same thing...
Quote:
Originally Posted by MyUndiesSmell
Посмотреть сообщение
You can use a stock to return a players name, it will be alot faster than typing that out each time.

Код:
CMD:rocketd(playerid, params[])
{
	new string[128];
	format(string, sizeof(string), {FFFFFF}%s {FFCC00}has entered the minigame of{FFFF00} [Rocket-Survive] {FFCC00}(/rocketd)", pName(playerid));
	SendClientMessageToAll(-1, string);
	return 1;
}

stock pName(playerid)
{
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, MAX_PLAYER_NAME);
      return name;
}
https://sampforum.blast.hk/showthread.php?tid=570635


Re: Help pls - TheToretto - 13.02.2019

Quote:
Originally Posted by MyUndiesSmell
Посмотреть сообщение
You can use a stock to return a players name, it will be alot faster than typing that out each time.

Код:
stock pName(playerid)
{
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, MAX_PLAYER_NAME);
      return name;
}
Just a plain function, the usage of stock is unnecessary in this case.