SA-MP Forums Archive
Preceding to level - 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: Preceding to level (/showthread.php?tid=608261)



Preceding to level - lwilson - 29.05.2016

Код:
(44826) : warning 219: local variable "engine" shadows a variable at a preceding level
PHP код:
new engine random(2)+1;
if(
f_vHealth 750)
                                    {
                                        if(
engine == 1)
                                        {
                                            
StopAudioStreamForPlayer(playerid);
                                            
PlayAudioStreamForPlayer(playerid"http://static1.grsites.com/archive/sounds/vehicle/vehicle011.mp3"xyz20.01);
                                            
SendClientMessageEx(playeridCOLOR_WHITE"Vehicle engine starting, please wait...");
                                            
SetTimerEx("SetVehicleEngine"30000"dd",  vehicleidplayerid);
                                            
format(stringsizeof(string), "** %s inserts the key in the ignition."GetPlayerNameEx(playerid));
                                            
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                            
format(stringsizeof(string), "** The engine of the vehicle starts. (( %s ))"GetPlayerNameEx(playerid));
                                            
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                        }
                                        if(
engine && < 3)
                                        {
                                            
StopAudioStreamForPlayer(playerid);
                                            
PlayAudioStreamForPlayer(playerid"http://static1.grsites.com/archive/sounds/vehicle/vehicle011.mp3"xyz20.01);
                                            
SendClientMessageEx(playeridCOLOR_WHITE"Vehicle engine starting, please wait...");
                                            
SetTimerEx("SetVehicleEngineFail"30000"dd",  vehicleidplayerid);
                                            
format(stringsizeof(string), "** %s inserts the key in the ignition."GetPlayerNameEx(playerid));
                                            
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                            
format(stringsizeof(string), "** The engine of the vehicle fails to start. (( %s ))"GetPlayerNameEx(playerid));
                                            
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                        }
                                    }
                                    } 



Re: Preceding to level - Nero_3D - 29.05.2016

It simply tells you that the variable 'engine' already exists somewhere before your second definition
That could be in the function itself on the same level or in any preceding level or it could be a global variable