Raised This Month: $ Target: $400
 0% 

SteamID and Username of Allies alive


Post New Thread Reply   
 
Thread Tools Display Modes
BenSib
Senior Member
Join Date: Aug 2008
Old 09-24-2008 , 06:39   Re: SteamID and Username of Allies alive
Reply With Quote #11

Trying to write these values (survivornames) to a textfile. I should add a line with:

native bool:WriteFileLine(Handle:hndl, const String:format[], any:...);

right?

thx

Last edited by BenSib; 09-24-2008 at 06:42.
BenSib is offline
BenSib
Senior Member
Join Date: Aug 2008
Old 09-29-2008 , 18:08   Re: SteamID and Username of Allies alive
Reply With Quote #12

That should do it:

PHP Code:
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
 
// create local string that we will add all survivors info to!
 
new String:survivornames[512]
 
 
// format the string so the hintmessage has the desired headline
 
Format(survivornamessizeof(survivornames), "Winners of the Medal of Honour:\n")
 
 
// now we go through all players
 
for(new 1GetMaxClients(); i++)
 {
  
// we're only looking for connected and alive players
  
if(IsClientInGame(i) && IsPlayerAlive(i))
  {
   
// we're only looking for U.S. Army
   
if(GetClientTeam(i) == ALLIES)
   {
    
//we found an allied player that's alive on roundend!
    
    // create strings for name and steamid
    
decl String:pl_steamid[32], String:pl_username[MAX_NAME_LENGTH]
    
    
// get player's name
    
GetClientName(ipl_usernamesizeof(pl_username))
    
    
// get player's steamid
    
GetClientAuthString(ipl_steamidsizeof(pl_steamid))
    
    
// create local string for survivor info
    
decl String:SurvivorInfo[64]
    
    
// merge playername and steamid into one string
    
Format(SurvivorInfosizeof(SurvivorInfo), "\n%s (%s)"pl_usernamepl_steamid)
    
    
// add info of this player to the string:
    
StrCat(survivornamessizeof(survivornames), SurvivorInfo)
   }
  }
 }
 
// display the hintmessage with all info we collected
  
SendPanelToAll(survivornames)
 return 
Plugin_Continue

 
// adds a line to a txt file called roundend.txt in addons/sourcemod/medals folder
        
new Handle:file OpenFile("roundend.txt""/addons/sourcemod/medals")
        if(
file != INVALID_HANDLE
            {
            
WriteFileLine(file,survivornames)
            
CloseHandle(file
            }



but nothing is written ...
BenSib is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 09-29-2008 , 18:12   Re: SteamID and Username of Allies alive
Reply With Quote #13

You need to put the file part before "return Plugin_Continue"

return ends the function, so everything after that is ignored.
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
BenSib
Senior Member
Join Date: Aug 2008
Old 09-29-2008 , 18:52   Re: SteamID and Username of Allies alive
Reply With Quote #14

oh, you are right, thx. But anyway, even if i put it like this, no write...

PHP Code:
 // display the hintmessage with all info we collected
  
SendPanelToAll(survivornames)

 
// adds a line to a txt file called roundend.txt in addons/sourcemod/medals folder
        
new Handle:file OpenFile("roundend.txt""/addons/sourcemod/medals")
        if(
file != INVALID_HANDLE
            {
            
WriteFileLine(file,survivornames)
            
CloseHandle(file
            }

 return 
Plugin_Continue 

Last edited by BenSib; 09-29-2008 at 19:29.
BenSib is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 09-29-2008 , 19:01   Re: SteamID and Username of Allies alive
Reply With Quote #15

You are using OpenFile incorrectly

http://docs.sourcemod.net/api/index....d=show&id=247&

Also, try using WriteFile instead of WriteFileLine

http://docs.sourcemod.net/api/index....d=show&id=810&
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
BenSib
Senior Member
Join Date: Aug 2008
Old 09-30-2008 , 03:15   Re: SteamID and Username of Allies alive
Reply With Quote #16

OK, thx for your help. Finally:

PHP Code:
        new Handle:fileHandle OpenFile("addons/sourcemod/medals/roundend.txt","a")
        if(
fileHandle != INVALID_HANDLE
            {
            
WriteFileLine(fileHandle,survivornames)
            
CloseHandle(fileHandle)
            }

 return 
Plugin_Continue 
The apprentice


EDIT: For those who also work with files I found a useful link:
https://forums.alliedmods.net/showthread.php?t=59192

Last edited by BenSib; 09-30-2008 at 03:36.
BenSib 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 02:25.


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