SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/10/2019, 06:26 PM   #1
PopularTech
Little Clucker
 
PopularTech's Avatar
 
Join Date: Dec 2018
Posts: 23
Reputation: 0
Default Need help please

Quote:
CMDdwarn(playerid, params[])
{
if(!IsLawEnforcement(playerid))
{
return SendClientMessage(playerid, COLOR_GREY, "You can't use this command as you aren't apart of law enforcement.");
}
else{
return cmd_me(playerid, "Freeze! San Andreas Police Department! Put your hands where i can see them now! ((/handsup))");
}
return 1;
}
It shows this error
Quote:
gamemode-jason.pwn(57090) : warning 225: unreachable code
__________________
𝕰𝖝𝖙𝖗𝖊𝖒𝖊 𝕽𝖔𝖑𝖊𝖕𝖑𝖆𝖞
Our Community Extreme Roleplay is based in the City of Los Santos. After several tries and a lot of stress we managed to get everything running and now our only goal is to build a big and succesful community where you guys can have fun roleplaying. We would appreciate if you would join this adventure with us! https://discord.gg/WqsWPsJ

PopularTech is offline   Reply With Quote
Old 27/10/2019, 12:55 AM   #2
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 992
Default Re: Need help please

The return keyword halts the execution of the function. You have three return statements. Two of them are in an if/else condition so one of them is guaranteed to be called. This means the third one at the bottom will never happen - hence unreachable code.

Remove the first two return statements and just return 1 at the bottom.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:35 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.