AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   write file (https://forums.alliedmods.net/showthread.php?t=339124)

Nutu_ 08-17-2022 17:40

write file
 
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?

fysiks 08-17-2022 22:09

Re: write file
 
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?

Nutu_ 08-18-2022 13:03

Re: write file
 
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

fysiks 08-18-2022 23:21

Re: write file
 
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.

Nutu_ 08-21-2022 08:15

Re: write file
 
Quote:

Originally Posted by fysiks (Post 2786834)
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!


All times are GMT -4. The time now is 15:32.

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