SA-MP Forums Archive
help. - 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. (/showthread.php?tid=630022)



help. - AndreaSanchez - 07.03.2017

PHP код:
        new gun GetPlayerWeapon(playerid);
* * * * if(
gun == || gun == || gun == 26 || gun == 34 || gun == 35 || gun == 36 || gun == 37 || gun == 38 || gun == 39)
* * {
* * * * new 
plname[MAX_PLAYER_NAME];
* * * * new 
string[128];
* * * * if(
Player[playerid][pAdmin] <= 1)
* * * * {
* * * * * * 
GetPlayerName(playeridplnamesizeof(plname));
* * * * * * 
format(stringsizeof(string), "{00FF00}[ÀÍÒÈ×ÈÒ]{FFFFFF}: {FF0000}%s {FFFFFF}áûë êèêíóò. Ïðè÷èíà: ÷èò íà îðóæèå!"plname);
* * * * * * 
SendAdminMessage(COLOR_LIGHTREDstring);
* * * * * * 
DelGun(playerid);
* * * * * * 
Kick(playerid);
* * * * }
* * } 
Hello, please help. ((336) : error 003: declaration of a local variable must appear in a compound block) - new gun = GetPlayerWeapon(playerid); Stars should not be. In the code they are not.


Re: help. - Toroi - 07.03.2017

Let the stars be whatever they want to be.

Don't use the variable, do it like this:

PHP код:
if(GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == || ..) 



Re: help. - AndreaSanchez - 07.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Let the stars be whatever they want to be.

Don't use the variable, do it like this:

PHP код:
if(GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == || ..) 
Does not work.


Re: help. - Toroi - 07.03.2017

How come? Does it give you error?


Re: help. - Stinged - 07.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Let the stars be whatever they want to be.

Don't use the variable, do it like this:

PHP код:
if(GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == || ..) 
Actually no. Using a variable is much better.
You're calling GetPlayerWeapon(playerid) multiple times, while with a variable you only call it once.

What's even better is using switch.

Post a couple of lines above the code you posted here.


Re: help. - Toroi - 07.03.2017

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Actually no. Using a variable is much better.
You're calling GetPlayerWeapon(playerid) multiple times, while with a variable you only call it once.

What's even better is using switch.

Post a couple of lines above the code you posted here.
I made an extensive search through my entire post, but I could not find the part where I tell the guy that using a variable was not good. Perhaps can you point it for me?

OP, waiting for your answer to see what's wrong with your code.


Re: help. - Stinged - 08.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I made an extensive search through my entire post, but I could not find the part where I tell the guy that using a variable was not good. Perhaps can you point it for me?

OP, waiting for your answer to see what's wrong with your code.
Quote:
Originally Posted by Troydere
Посмотреть сообщение
Don't use the variable, do it like this:
You're saying that he shouldn't use a variable to store the weapon id, he should instead call GetPlayerWeapon multiple times.


Re: help. - Toroi - 08.03.2017

Quote:
Originally Posted by Stinged
Посмотреть сообщение
You're saying that he shouldn't use a variable to store the weapon id, he should instead call GetPlayerWeapon multiple times.
http://www.wikihow.com/Solve-a-Problem


Re: help. - SyS - 02.04.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Let the stars be whatever they want to be.

Don't use the variable, do it like this:

PHP код:
if(GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == || ..) 
Dont do it. Why to provide multiple overhead for getting same value? you can save some memory and performance by store and use method.


Re: help. - GhostHacker9 - 02.04.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Let the stars be whatever they want to be.

Don't use the variable, do it like this:

PHP код:
if(GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == || ..) 
You complains a lot about having this type of declaration
PHP код:
new 
      
item
But you suggest the most inefficient way to script. How moronic is that?