AlliedModders

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

CryWolf 08-21-2013 06:03

File write / read
 
hy allied modders users, i have a amxx plugin with i am trying to write details from users who tipe comand in chat to a file, name, steamid and ip, i've recently updated to not allow 2 same names to be written and for my surprise it does'nt work anymore, it creates the file in configs but it's empty and when i type the comand it said that i already exist in the file, but the file is empty what's wrong with this code

Thanks for read and help

And it will be helpfull if you can tell me how to print users from that file to a motd

Sorry for my bad english i suck at it :|

File removed!

jimaway 08-21-2013 06:30

Re: File write / read
 
its not really good idea to keep reading the file several times, do it once and save the names to a dynamic array or something like that.

also was your name CryWolf when you tested it, cause i saw this in the code:
Code:

if ( !filep )
        {
                write_file ( filen, "; File Names, 0.3 by CryWolf." );
                write_file ( filen, "; Format: [ date ] < username > | < SteamID > | < IP >" );
        }

and you check for the names like this:
Code:

if ( containi ( szData, szName ) )

CryWolf 08-21-2013 06:43

Re: File write / read
 
nope, my name was JasoN when i tested it!
btw i think you did not understand me plugin problems are
1. File is created but it's always empty even these are not on it
Code:

write_file ( filen, "; File Names, 0.3 by CryWolf." );
                write_file ( filen, "; Format: [ date ] < username > | < SteamID > | < IP >" );

2. I can't not use the comand it said that i am already on the list

and 3rd i whanna know how to read names from file and print it to a motd, i don't need to optimize nothing yet

AMXX 1.8.2
Metamod12.1-am

Arkshine 08-21-2013 08:02

Re: File write / read
 
If your code, you should be able to debug it. Right now you're saying "it doesn't work", but it's supposed to be your code, did you at least tried to debug it ? Like adding debug text, testing line by line, and such ?

CryWolf 08-21-2013 08:10

Re: File write / read
 
Quote:

Originally Posted by Arkshine (Post 2018622)
If your code, you should be able to debug it. Right now you're saying "it doesn't work", but it's supposed to be your code, did you at least tried to debug it ? Like adding debug text, testing line by line, and such ?

Normaly i avoid guy's like you, but in this case i whanna tell you to avoid my topics please if you don't bring me nothing helpfully!
Thanks, i shall remake it without that function! debug mode helps me with nothing!

YamiKaitou 08-21-2013 09:03

Re: File write / read
 
Quote:

Originally Posted by CryWolf (Post 2018628)
Normaly i avoid guy's like you, but in this case i whanna tell you to avoid my topics please if you don't bring me nothing helpfully!
Thanks, i shall remake it without that function! debug mode helps me with nothing!

You are here asking for assistance and then you bash someone trying to help you? Saying "doesn't work" doesn't help us in determining what is actually wrong

Arkshine 08-21-2013 09:03

Re: File write / read
 
That's not your code then. Ok, thanks for confirmation.

Anyway, what I said is still valid, you should start to _debug_ "this" code. I did not say to add "debug" in plugins.ini. It's weird as coder you don't know to check your own code. I DO help you by saying what you should do, but don't worry I won't waste my time for someone who because don't understand something bash the helper.

CryWolf 08-21-2013 09:19

Re: File write / read
 
Quote:

Originally Posted by Arkshine (Post 2018653)
That's not your code then. Ok, thanks for confirmation.

Anyway, what I said is still valid, you should start to _debug_ "this" code. I did not say to add "debug" in plugins.ini. It's weird as coder you don't know to check your own code. I DO help you by saying what you should do, but don't worry I won't waste my time for someone who because don't understand something bash the helper.

I don't sleep at night with C++ / Pawn book on my chest like you do it, i have other thing in my life to do (better ones)
Of course it's not my code: i've just followed a tutorial this one in achiving what i've made.
That is not the point i didn't come here to argue, i've removed the function that verifies that the same player is not added twice to that list and solved. i will find somewere else a little help with fixing that!

@YamiKaitou: what do you find helpfull in his first reply ? that is asking me if is my code or not and what's that have someting to do with what i've requested!

Please guy's close the tread, this doesn't need to go further.

Thanks for help, and i'am sorry for disturb and trouble, it will not happen again!

Arkshine 08-21-2013 09:39

Re: File write / read
 
Quote:

did you at least tried to debug it ? Like adding debug text, testing line by line, and such
Instead of focusing on irrelevant part, did you do that ? I guess not.
Just because you don't understand that, doesn't mean you are allowed to bash someone, because for your information I was helping you.

You should have said clearly from the start that :

- That's not your code
- You are beginner
- What you have tried

That's said, since you're posting in Scripting section, you're willing to learn, right ? So, I say it again, debug your plugin : adding debug text with for example log_amx() to see if code is well executed, checking line by line to narrow down where is lying the problem, etc.

.Dare Devil. 08-21-2013 10:53

Re: File write / read
 
Quote:

Originally Posted by CryWolf (Post 2018657)
I don't sleep at night with C++ / Pawn book on my chest like you do it, i have other thing in my life to do (better ones)

What a waste is to put than on your chest!
If you but that book under the pillow, then see results!
Thats how i learned and learn everyday. :bee:


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

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