Raised This Month: $ Target: $400
 0% 

BuildPath in F:/


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leabut
Junior Member
Join Date: May 2010
Old 05-31-2010 , 17:44   BuildPath in F:/
Reply With Quote #1

Hello Guys,

I tried something for the last 3 hours.

The use of the buildpath() command.

But I dont know how to use it right.

I want to change the save dir of the config/save files of my roleplay plugin.

The code ist
PHP Code:
//Map Start:
public OnMapStart()
{

    
//Saving:
    
BuildPath(Path_SMSavePath64"data/roleplay/save.txt");
    if(
FileExists(SavePath) == falseSetFailState("[SM] ERROR: Missing file '%s'"SavePath);

[...] 
All right.

I want to change the save dir from C:/Server/hl2mp/addons/sourcemod/data/roleplay
to
F:/www/test/data/roleplay

but how?

I tried
PHP Code:
 BuildPath(Path_NoneSavePath64"F:/www/test/data/roleplay/save.txt"); 
But I get an error on compiling



I also used
PHP Code:
BuildPath(Path_SMSavePath64,  "file://F:/www/test/data/roleplay/save.txt"); 
But it didnt work.

If i start my server it says, file not found "sourcemod/file://F:/www/test/data/roleplay/save.txt"

I also tried
PHP Code:
BuildPath(Path_SMSavePath64,  "../../../../F:/www/test/data/roleplay/save.txt"); 
But same problem, says, file not found "sourcemod/../../../../F:/www/test/data/roleplay/save.txt"

I also tried
PHP Code:
BuildPath(Path_SMSavePath64,   "F:\www/test/data/roleplay/save.txt"); 
But than I get an error on compileing, that the "\" is not allowed!

What could i do?

Full plugin as file: http://leabut.kilu.de/support/rp_main.sp
__________________

Last edited by Leabut; 06-01-2010 at 07:10. Reason: changed code to php
Leabut is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-31-2010 , 18:08   Re: BuildPath in F:/
Reply With Quote #2

Please read the function documentation before attempting to use it.
Quote:
Builds a path relative to the SourceMod folder. This should be used instead of directly referencing addons/sourcemod, in case users change the name of their folder layout.
You want OpenFile("file://F:/www/test/data/roleplay/save.txt","w");
__________________
plop
p3tsin is offline
Leabut
Junior Member
Join Date: May 2010
Old 05-31-2010 , 18:42   Re: BuildPath in F:/
Reply With Quote #3

Thank you very much, for your reply but,

sry I dont understand the usage of the
OpenFile Command

I read this
PHP Code:
 native Handle:OpenFile(const String:file[], const String:mode[]); 

but I dont understand what "const" or "String:file[]," means.

Its the first time I am scripting.

But I need to set the dir (
file://F:/www/test/data/roleplay/save.txt) to the text
PHP Code:
if(FileExists(SavePath
SavePath I think, because if SavePath does not exist it bugs my whole scritp!
Because later there comes this
PHP Code:
//Store:
                
KeyValuesToFile(SaveVaultSavePath); 
But dont know how to set

Last edited by Leabut; 05-31-2010 at 20:23. Reason: changed co
Leabut is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-31-2010 , 19:28   Re: BuildPath in F:/
Reply With Quote #4

To give you a prod to the right direction:
PHP Code:
strcopy(SavePath,sizeof(SavePath),"file://F:/www/test/data/roleplay/save.txt"); 
You can forget about the OpenFile part since you'll be dealing with keyvalues.

I strongly suggest you read this before going any further though: http://wiki.alliedmods.net/Introduction_to_SourcePawn
__________________
plop

Last edited by p3tsin; 05-31-2010 at 19:33. Reason: meh
p3tsin is offline
Leabut
Junior Member
Join Date: May 2010
Old 05-31-2010 , 20:18   Re: BuildPath in F:/
Reply With Quote #5

My momentally script is
PHP Code:
//Map Start:
public OnMapStart()
{

    
//Saving:
    
strcopy(SavePath,sizeof(SavePath),"P:/www/test/data/roleplay/save.txt");
    if(
FileExists(SavePath) == falseSetFailState("[SM] ERROR: Missing file '%s'"SavePath);

    
//Job DB:
    
strcopy(JobPath,sizeof(JobPath),"P:/www/test/data/roleplay/jobs.txt");
    if(
FileExists(JobPath) == falseSetFailState("[SM] ERROR: Missing file '%s'"JobPath);

    
//NPC DB:
    
strcopy(NPCPath,sizeof(NPCPath),"P:/www/test/data/roleplay/npcs.txt");
    if(
FileExists(NPCPath) == falseSetFailState("[SM] ERROR: Missing file '%s'"NPCPath);

    
//Config DB:
    
strcopy(ConfigPath,sizeof(ConfigPath),"P:/www/test/data/roleplay/config.txt");
    if(
FileExists(ConfigPath) == false)SetFailState("[SM] ERROR: Missing file '%s'"ConfigPath);
    
        
//Lock DB:
        
strcopy(LockPath,sizeof(LockPath),"P:/www/test/data/roleplay/lock.txt");
        if(
FileExists(LockPath) == false)SetFailState("[SM] ERROR: Missing file '%s'"LockPath);

    
//Config DB:
    
strcopy(ItemPath,sizeof(ItemPath),"P:/www/test/data/roleplay/items.txt");
    if(
FileExists(ItemPath) == falseSetFailState("[SM] ERROR: Missing file '%s'"ItemPath);
    
    
//Config DB:
        
strcopy(DownloadPath,sizeof(DownloadPath),"P:/www/test/data/roleplay/download.txt");
        if(
FileExists(DownloadPath) == falseSetFailState("[SM] ERROR: Missing file '%s'"DownloadPath);

    
    
//Name DB:
    
strcopy(NamePath,sizeof(NamePath),"P:/www/test/data/roleplay/names.txt");
    if(
FileExists(NamePath) == falsePrintToConsole(0"[SM] ERROR: Missing file '%s'"NamePath);

    
//Opened:
    //if(SaveVault != INVALID_HANDLE) CloseHandle(SaveVault);
    
SaveVault CreateKeyValues("Vault");
    if(!
FileToKeyValues(SaveVaultSavePath)) SetFailState("[SM] ERROR: Missing File '%s'"SavePath);


    
//Declare:
[...] 
The strcopy is working but it still didnt find the file.
(Dont worry about the F:/ I changed it to P:/)



€dit:

I also tried the script with
Code:
    //Saving:
     strcopy(SavePath,sizeof(SavePath),"file://P:/www/test/data/roleplay/save.txt");
    if(FileExists(SavePath) == false) SetFailState("[SM] ERROR: Missing  file '%s'", SavePath);
Still same problem

€dit2:

I also tried with C:/ without P:/

Still the same

€dit3:

Btw. what do I wanna do with this.

First, I want to make 2 RolePlay Servers on two diffrent Computers, but I dont know how to synchronize those two servers.
Over SQL it my work, but I have no skills in SQL etc.
So I tried to make an own Hard Disk over FTP for those Computers to synchronozie them.
That they use the same save/config files so, that players can join from server 1 to server 2 and have still the same money and appartments etc.

But if you could help me with SQL it might be good as well, but I think over a Hard Disk via FTP it could be some easier

Last edited by Leabut; 05-31-2010 at 20:49. Reason: added sth
Leabut is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 06-01-2010 , 08:26   Re: BuildPath in F:/
Reply With Quote #6

Quote:
Originally Posted by Leabut View Post
€dit:

I also tried the script with
Code:
    //Saving:
     strcopy(SavePath,sizeof(SavePath),"file://P:/www/test/data/roleplay/save.txt");
    if(FileExists(SavePath) == false) SetFailState("[SM] ERROR: Missing  file '%s'", SavePath);
Still same problem

€dit2:

I also tried with C:/ without P:/

Still the same

€dit3:

Btw. what do I wanna do with this.

First, I want to make 2 RolePlay Servers on two diffrent Computers, but I dont know how to synchronize those two servers.
Over SQL it my work, but I have no skills in SQL etc.
So I tried to make an own Hard Disk over FTP for those Computers to synchronozie them.
That they use the same save/config files so, that players can join from server 1 to server 2 and have still the same money and appartments etc.

But if you could help me with SQL it might be good as well, but I think over a Hard Disk via FTP it could be some easier
I assume P: is a network drive. This is just a guess but I think SourceMod can only access local drives. And even if it was local, FileToKeyValues is using valve's filesystem and that doesn't support literal paths.

You should seriously consider using SQL instead. Take a look at the tutorial in the wiki and other plugins using SQL. Its not that complex.
__________________
plop
p3tsin 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 09:40.


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