AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]read first line of .txt file (https://forums.alliedmods.net/showthread.php?t=75872)

padilha007 08-13-2008 18:39

[SOLVED]read first line of .txt file
 
PHP Code:

public pegar(id) {
new 
data[64]
new 
mapname[32
get_mapname(mapname,31

static 
text[32]; 
formatextext255"addons/amxmodx/configs/spawn/%s.txt"mapname );
fgets(fopen(text"text"), data63)
server_cmd("amx_numb %s"text)


but dont work, dont get any text.

Emp` 08-13-2008 19:13

Re: read first line of .txt file
 
PHP Code:

public pegar(id) {
new 
data[64]
new 
mapname[32
get_mapname(mapname,31

static 
text[128]; 
formatextext127"addons/amxmodx/configs/spawn/%s.txt"mapname );
fgets(fopen(text"rt"), data63)
server_cmd("amx_numb %s"data)


data has the first line.

padilha007 08-13-2008 20:24

Re: read first line of .txt file
 
my first line is -138 400 60

but your code get just 1 number -138, can i get 3 only?

Xanimos 08-14-2008 12:56

Re: read first line of .txt file
 
Then it has something to do with the code that deals with the "amx_numb" command.

padilha007 08-14-2008 17:04

Re: read first line of .txt file
 
yeah, i use amx_numb fo this:

new coords[32]
get_cvar_string("amx_numb", coords, 31)
write_file( text , coords , 0);

I need get this number, using Emp` code, but i get just 1 number.
in file have: 100 100 100

but get just one, 100

Emp` 08-15-2008 02:48

Re: read first line of .txt file
 
try
Code:

public pegar(id) {
new data[64]
new mapname[32]
get_mapname(mapname,31)

static text[128];
formatex( text, 127, "addons/amxmodx/configs/spawn/%s.txt", mapname );
fgets(fopen(text, "rt"), data, 63)
server_cmd("amx_numb ^"%s^"", data)
}


padilha007 08-15-2008 18:29

Re: read first line of .txt file
 
work. tnx +karma


All times are GMT -4. The time now is 03:06.

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