Raised This Month: $ Target: $400
 0% 

Please fix code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 06:38   Please fix code
Reply With Quote #1

When I wrote the wrong forum to ask for a transfer.
I have a problem, the plugin does not create a Steam_ID.ini files in folder 'czas_gry'.
Normally, game time is calculated on the server, but after leaving the server removes the time.

Please someone to improved code.
Sorry for my bad English.
I greet.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

new gszFile[201], czas[33], szDir[64];

public 
plugin_init()
{
        
rregister_plugin("Czas gry""1.0""naXe");
        
register_clcmd("say /czasgry""pokaz_czas_gry");
        
register_clcmd("say_team /czasgry""pokaz_czas_gry");
        
register_clcmd("say /czas""pokaz_czas_gry");
        
register_clcmd("say_team /czas""pokaz_czas_gry");
        
get_basedir(szDirsizeof szDir);
        
formatex(gszFile200"%s/configs/czas_gry/"szDir);
}
public 
client_putinserver(id)
{
        if(!
is_user_steam(id))
        {
                return 
PLUGIN_CONTINUE;
        }
        new 
steam_id[35], adres[201], iLenText[32];
        
get_user_authid(idsteam_idsizeof steam_id 1);
        
formatex(adres200"%s/%s.ini"gszFilesteam_id);
        if(
file_exists(adres))
        {
                
read_file(adres0Text31iLen);
                
trim(Text);
                
czas[id] = str_to_num(Text);
        }
        else
        {
                
czas[id] = 0;
        }
        return 
PLUGIN_HANDLED;
}
public 
pokaz_czas_gry(id)
{
        if(!
is_user_steam(id))
        {
                return 
PLUGIN_HANDLED;
        }
        new 
iCurTime get_user_timeid );
        new 
Time czas[id];
        if((
iCurTime Time) / 60 60)
        {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 min.", (iCurTime Time) / 60);
        }
        else
        {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 h ^x03%02d^x01 min.", (iCurTime Time) / 3600, ((iCurTime Time) / 60) % 60);
        }
        return 
PLUGIN_HANDLED;
}
public 
client_disconnect(id)
{
        if(!
is_user_steam(id))
        {
                return 
PLUGIN_HANDLED;
        }
        new 
steam_id[35], adres[201], Text[200];
        
get_user_authid(idsteam_idsizeof steam_id 1);
        
formatex(adres200"%s/%s.ini"gszFilesteam_id);
        new 
szTime get_user_timeid ) + czas[id];
        
num_to_str(szTimeTextcharsmax(Text));
        
write_file(adresText0);
        return 
PLUGIN_HANDLED;
}
stock bool:is_user_steam(id)
{
        new 
authid[35]; 
        
get_user_authid(idauthidsizeof authid 1);
        return 
contain(authid ":") != -true false;

naXe is offline
Send a message via AIM to naXe
echo_cs
Senior Member
Join Date: Dec 2011
Old 02-11-2012 , 12:56   Re: Please fix code
Reply With Quote #2

Not Correct:
PHP Code:
 if(!is_user_steam(id)) 
        { 
                return 
PLUGIN_HANDLED
        } 
This is The Correct:
PHP Code:
new SteamID[50]
new 
Steam get_user_authid(idSteamID49)

if(
Steam == STEAM_ID_LAN)
    return 
PLUGIN_CONTINUE 
__________________
Pawn (5%)

C (80%)

C++ (20%)

SQL (5%)

Last edited by echo_cs; 02-11-2012 at 12:56.
echo_cs is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2012 , 13:05   Re: Please fix code
Reply With Quote #3

All users have a proper SteamID on a Steam server. If they don't then you won't get any support here.

Quote:
Originally Posted by echo_cs View Post
Not Correct:
PHP Code:
 if(!is_user_steam(id)) 
        { 
                return 
PLUGIN_HANDLED
        } 
This is The Correct:
PHP Code:
new SteamID[50]
new 
Steam get_user_authid(idSteamID49)

if(
Steam == STEAM_ID_LAN)
    return 
PLUGIN_CONTINUE 
That is even worse than what he had.
__________________
fysiks is online now
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 13:10   Re: Please fix code
Reply With Quote #4

Improve someone? Please.
naXe is offline
Send a message via AIM to naXe
Old 02-11-2012, 13:15
echo_cs
This message has been deleted by echo_cs. Reason: Sorry
echo_cs
Senior Member
Join Date: Dec 2011
Old 02-11-2012 , 13:16   Re: Please fix code
Reply With Quote #5

Im Sorry I don't Read all The script

PHP Code:
stock bool:is_user_steam(id

        new 
authid[35];  
        
get_user_authid(idauthidsizeof authid 1); 
        return 
contain(authid ":") != -true false

This is correct
__________________
Pawn (5%)

C (80%)

C++ (20%)

SQL (5%)
echo_cs is offline
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 13:48   Re: Please fix code
Reply With Quote #6

Ok.

But there is a problem because I did not create the file: STEAM_ID: BLABLA.ini

And time is not saves.
naXe is offline
Send a message via AIM to naXe
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2012 , 21:01   Re: Please fix code
Reply With Quote #7

Quote:
Originally Posted by naXe View Post
Ok.

But there is a problem because I did not create the file: STEAM_ID: BLABLA.ini

And time is not saves.
First, remove the is_user_steam() from the plugin completely (Everybody has a SteamID!)

I will give you a hint though, just for fun: Only certain characters can be used in filenames.
__________________
fysiks is online now
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 23:04   Re: Please fix code
Reply With Quote #8

is_user_steam () must be because the server is 47 +48
save has only players with Steam

I know that you can not just some characters I did like this:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
 
new gszFile[201], czas[33], szDir[64]
 
public 
plugin_init() {
        
register_plugin("Czas gry""1.0""naXe")
        
register_clcmd("say /czasgry""pokaz_czas_gry")
        
register_clcmd("say /czas""pokaz_czas_gry")
       
        
get_basedir(szDirsizeof szDir)
        
formatex(gszFile200"%s/configs/czas_gry/"szDir)
       
}
public 
client_putinserver(id) {
        if(
is_user_steam(id)) {
                new 
steam_id[35], adres[201], iLenText[32]
                
get_user_authid(idsteam_idsizeof steam_id 1)
                
replace(steam_id,charsmax(steam_id),":","-")
                
formatex(adres200"%s%s.ini"gszFilesteam_id)
                if(
file_exists(adres)) {
                        
read_file(adres0Text31iLen)
                        
trim(Text)
                        
czas[id] = str_to_num(Text)
                } else {
                        
czas[id] = 0
                
}
        }
        return 
PLUGIN_HANDLED
}
public 
pokaz_czas_gry(id) {
        new 
iCurTime get_user_time(id 1)
        new 
Time czas[id]
        if((
iCurTime Time) / 60 60) {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 min.", (iCurTime Time) / 60)
        } else {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 h ^x03%02d^x01 min.", (iCurTime Time) / 3600, ((iCurTime Time) / 60) % 60)
        }
        return 
PLUGIN_HANDLED
}
public 
client_disconnect(id) {
        if(
is_user_steam(id))  {
                new 
steam_id[35], adres[201], Text[200]
                
get_user_authid(idsteam_idsizeof steam_id 1)
                
replace(steam_id,charsmax(steam_id),":","-")
                
formatex(adres200"%s%s.ini"gszFilesteam_id)
                new 
szTime get_user_time(id 1) + czas[id]
                
num_to_str(szTimeTextcharsmax(Text))
                
write_file(adresText0)
        }
        return 
PLUGIN_HANDLED
}
 
stock bool:is_user_steam(id) {
        new 
authid[32]
        
get_user_authid(idauthid31)
        return 
contain(authid ":") != -true false

naXe is offline
Send a message via AIM to naXe
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-11-2012 , 23:49   Re: Please fix code
Reply With Quote #9

Quote:
Originally Posted by naXe View Post
is_user_steam () must be because the server is 47 +48
save has only players with Steam
We don't allow support for Non-Steam here.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 23:07.


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