I need Help Again =]]z
#1

Warning : /includes/NGGv5.1.pwn(99319) : warning 219: local variable "string" shadows a variable at a preceding level

That line : new string[128];
format(string, sizeof(string), "Hay Deo Day An Toan Vao De Bao Ve Mang Song Cua Ban((/sb))");
SendClientMessage(playerid, 0xFFFFFFAA, string);

i Put that line under public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
Reply
#2

there is already a string defined as "string" etc you have defined it 2x new string and again new string
change to
Код:
new stringg[128];
format(stringg,sizeof(stringg),"Hay Doe Day An Toan Vao De Bao Ve Mang Song Cua Ban ((/sb))");
SendClientMessage(playerid,0xFFFFFFAA,stringg);
Reply
#3

You don't need to use format since there is no variable in your message. Simply do:

Код:
SendClientMessage(playerid,0xFFFFFFAA,"Hay Doe Day An Toan Vao De Bao Ve Mang Song Cua Ban ((/sb))");
Reply
#4

Quote:
Originally Posted by Spmn
Посмотреть сообщение
You don't need to use format since there is no variable in your message. Simply do:

Код:
SendClientMessage(playerid,0xFFFFFFAA,"Hay Doe Day An Toan Vao De Bao Ve Mang Song Cua Ban ((/sb))");
The first time I heard this, I was like 'what? what do you mean I don't have to use a 'format' '.
Well let me explain you.

Format is mainly used for variables.
Example 1 (wrong way to use format)
PHP код:
format(stringsizeof string"Hello I am happy."); 
Do you see? You have got no variable to specify. In this case you just use SendClientMessage.

Example 2 (correct way to use format)
PHP код:
format(stringsizeof string"%s is happy."pName); 
Do you see the difference? in this format you specified a variable.

I hope you understood this.

(( Pretend as if the string/pName variable is already defined. ))
Reply
#5

There's no wrong way to use format.

Let's for example have this:

PHP код:
new str[128];
if(
phidden[playerid])
    
format(strsizeof(str), "Someone typed this.");
else
    
format(strsizeof(str), "%s typed this."name); 
You won't need to retype the whole logic in an if statement.
But yes, if you don't see yourself doing an if statement to edit the string, then just use SCM.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)