#1

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.
Reply
#2

Let the stars be whatever they want to be.

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

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

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.
Reply
#4

How come? Does it give you error?
Reply
#5

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.
Reply
#6

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.
Reply
#7

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.
Reply
#8

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
Reply
#9

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.
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)