Raised This Month: $51 Target: $400
 12% 

write file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-17-2022 , 17:40   write file
Reply With Quote #1

PHP Code:
format(content,charsmax(content),"^"%s^" ^"^" ^"t^" ^"ce^" ;%s",authidname)
                
write_file("addons/amxmodx/configs/users.ini",content,-1)
                
server_cmd"amx_reloadadmins" ); 
is there an easier way to add an admin like this? i'm using this in a shop plugin and if someone buys VIP, it will automatically be added to users.ini like this.. and about an ^n to not be written after the last admin in users.ini?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-17-2022 , 22:09   Re: write file
Reply With Quote #2

Use the command that already exists: amx_addadmin. If that doesn't do everything you want then I think what you're doing is what you need to do.

And, what is your question about the newline character?
__________________
fysiks is online now
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-18-2022 , 13:03   Re: write file
Reply With Quote #3

well the first one who bought VIP from the shop, wasn't added under the last person on users.ini and after him..
i asked because i saw that
PHP Code:
set_user_flags(idVIP_FLAG); 
but i didn't know how it works
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-18-2022 , 23:21   Re: write file
Reply With Quote #4

Add a ^n to the beginning of the content string in the format function.

set_user_flags() will enable a user's flags in memory (which means it will only last during the current map). So, if you set the "t" flag (with ADMIN_LEVEL_H) then that player will have that flag during the current map. If that's all you want then you can just do that but to make it persistent, writing it to a file so that it gets loaded later is the way to go. However, depending on what you're trying to acheive, you may need to make sure that they keep the "z" flag so that they don't get other admin powers.
__________________
fysiks is online now
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-21-2022 , 08:15   Re: write file
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Add a ^n to the beginning of the content string in the format function.

set_user_flags() will enable a user's flags in memory (which means it will only last during the current map). So, if you set the "t" flag (with ADMIN_LEVEL_H) then that player will have that flag during the current map. If that's all you want then you can just do that but to make it persistent, writing it to a file so that it gets loaded later is the way to go. However, depending on what you're trying to acheive, you may need to make sure that they keep the "z" flag so that they don't get other admin powers.
got it! thank you!
__________________
a simple act of caring creates an endless ripple.
Nutu_ 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 00:11.


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