Raised This Month: $32 Target: $400
 8% 

Solved Loose identation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nG_getwreck
Senior Member
Join Date: Oct 2020
Location: Philippines from South K
Old 02-10-2021 , 21:55   Loose identation
Reply With Quote #1

I have problem on this part, the compiler says "loose identation" even though it's alined properly. What's wrong about this?

PHP Code:
public native_ze_give_crimsonhunt(id)
{
    if(!
is_user_connected(id))
    return -
1

    get_item
(id)
    return 
true

__________________

Last edited by nG_getwreck; 02-11-2021 at 05:07.
nG_getwreck is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-10-2021 , 22:18   Re: Loose identation
Reply With Quote #2

You can't just post a snippet and expect an answer. Post the whole code.
__________________
Spirit_12 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-10-2021 , 22:33   Re: Loose identation
Reply With Quote #3

Loose indentation means that your code is not properly indented. I.e. each scope (e.g. within braces) needs to be indented at the same depth. Also, you cannot mix spaces and tabs (IMO, always use tabs for indentation).
__________________
fysiks is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-10-2021 , 22:44   Re: Loose identation
Reply With Quote #4

PHP Code:
public native_ze_give_crimsonhunt(id)
{
    if(!
is_user_connected(id))
        
    return -
1
    
    get_item
(id)
    
    return 
true

try this

Last edited by lexzor; 02-10-2021 at 22:45.
lexzor is offline
nG_getwreck
Senior Member
Join Date: Oct 2020
Location: Philippines from South K
Old 02-11-2021 , 00:17   Re: Loose identation
Reply With Quote #5

Quote:
Originally Posted by Spirit_12 View Post
You can't just post a snippet and expect an answer. Post the whole code.
That's the part where the compiler highlighted, no need of posting the whole code.
__________________
nG_getwreck is offline
nG_getwreck
Senior Member
Join Date: Oct 2020
Location: Philippines from South K
Old 02-11-2021 , 00:18   Re: Loose identation
Reply With Quote #6

Quote:
Originally Posted by lexzor View Post
PHP Code:
public native_ze_give_crimsonhunt(id)
{
    if(!
is_user_connected(id))
        
    return -
1
    
    get_item
(id)
    
    return 
true

try this
Ok this one works thanks.
__________________
nG_getwreck is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-11-2021 , 06:40   Re: Loose identation
Reply With Quote #7

Simply use brackets instead of ugly code.

Code:
if(!is_user_connected(id)) {     return -1 }
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-11-2021 , 13:31   Re: Loose identation
Reply With Quote #8

Quote:
Originally Posted by nG_getwreck View Post
That's the part where the compiler highlighted, no need of posting the whole code.
Huh? You need to learn more code to understand why I said that.
__________________
Spirit_12 is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 02-14-2021 , 10:46   Re: Loose identation
Reply With Quote #9

Code:
public native_ze_give_crimsonhunt(id)
{

if(!is_user_connected(id))
{
abort(AMX_ERR_NATIVE, "Player not connected, id: %d", id);
}

give_item(id);
}
this is my way i saw a native perfect, using abort native for futher plugins error, in case they exists.
Also, use brackets to ident you code. If you use AMX Mod X Studio press CTRL+I for auto-ident and see where your code goes wrong.
__________________
LondoN is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 02-14-2021 , 11:02   Re: Loose identation
Reply With Quote #10

Quote:
Originally Posted by LondoN View Post
Code:
abort(AMX_ERR_NATIVE, "Player not connected, id: %d", id);
this is my way i saw a native perfect, using abort native for futher plugins error, in case they exists
http://www.amxmodx.org/api/amxmodx/abort

PHP Code:
Note

Warning
This function should not be used inside error filtersmodule
filters 
(native filters are safe if trap equals 1) or the
plugin_natives
() forward
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 20:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode