autoreset XP when someone for example reach 100000 XP -help!

Read log files for errors! If this fails, come here for help

Moderator: Forum Moderator

Post Reply
Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

autoreset XP when someone for example reach 100000 XP -help!

Post by Ufol » Wed Dec 13, 2006 7:29 am

War3ft Version: WC3:FT v2.3.2
Amxmodx Version: AMXX v1.76b
Metamod Version: MM v1.19p28

Hello ! {Sory for my bad english}
As the subject says I want to set autoreset xp for people who have 100 000 xp.
I was searching in google, forums for many hours and I don't find the solutions.
On my serwer XP save's to file cstrike/addons/amxmodx/data/amxx.db - it's meybe not easy for edit but work's fine...
If Any plugin or modifications exist ( I'm sure that exist becaouse many serwer's use somethink like that ) I beg you tell me what it's...

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Wed Dec 13, 2006 8:27 am

Best way to do this is to cron job a mysql script which will just update the database automatically...
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Wed Dec 13, 2006 8:46 am

Geesu can you give me some more usefull informations about that ??

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Wed Dec 13, 2006 9:54 pm

not w/o actually doing it - and i wouldn't want to spend time on it... but google:

cronjob... mysql command line usage

and the delete statement would be like

DELETE FROM `war3users` WHERE `xp` > 100000;
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Thu Dec 14, 2006 3:30 am

I have got better idea, to write some code in Xp.inl and compile it.
Please help to modyficate this code or create new:

[small]// Reset the user's XP when someone have some xp to 0
public XP_Resett(id)
{


if (XP>100000)
return PLUGIN_CONTINUE;

p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

XP_Save(id);

WAR3_Display_Level(id, DISPLAYLEVEL_NONE);

client_print(id, print_chat, "%s %L", g_MODclient, id, "YOUR_XP_HAS_BEEN_RESET");

return PLUGIN_CONTINUE;
}
[/small]
When I compile It there is an error: udefinen symbol XP .
What I must write to replace "XP" in correct code ?
Maybe that " if ( p_data[id][P_XP] > 100000 ) " is correct ?????
Someone plz help ?!
Last edited by Ufol on Sat Dec 16, 2006 10:20 am, edited 1 time in total.

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Thu Dec 14, 2006 11:12 am

Anywhone know code in war3FT ?? and how to modificate it ??

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Thu Dec 14, 2006 4:21 pm

you would want the change in the save function - so if when it saves if XP > 100000 it sets to 0

i.e.

[small]// Save the user's XP
public DB_SaveXP( id )
{

if ( id >= TASK_SAVE )
{
id -= TASK_SAVE;
}

if ( !WC3_Check() )
{
return;
}

new iRaceID = p_data[id][P_RACE];

if ( iRaceID == 0 || !get_pcvar_num( CVAR_wc3_save_xp ) || p_data[id][P_XP] == 0 )
{
return;
}

// Allow bot's XP to be saved if we're saving by name
if ( is_user_bot( id ) && get_pcvar_num( CVAR_wc3_save_by ) != DB_SAVEBY_NAME )
{
return;
}

// We don't want to save their XP if they cheated and got level 10!!!
if ( g_bGivenLevel10[id][iRaceID] )
{
return;
}

// Save the XP
switch( g_DBType )
{
case DB_MYSQLX: MYSQLX_Save( id );
case DB_SQLITE: SQLITE_Save( id );
case DB_VAULT: NVAULT_Save( id );
}

return;
}[/small]

should be

[small]// Save the user's XP
public DB_SaveXP( id )
{

if ( id >= TASK_SAVE )
{
id -= TASK_SAVE;
}

if ( !WC3_Check() )
{
return;
}

new iRaceID = p_data[id][P_RACE];

if ( iRaceID == 0 || !get_pcvar_num( CVAR_wc3_save_xp ) || p_data[id][P_XP] == 0 )
{
return;
}

// Allow bot's XP to be saved if we're saving by name
if ( is_user_bot( id ) && get_pcvar_num( CVAR_wc3_save_by ) != DB_SAVEBY_NAME )
{
return;
}

// We don't want to save their XP if they cheated and got level 10!!!
if ( g_bGivenLevel10[id][iRaceID] )
{
return;
}


if ( p_data[id][P_XP] > 100000 )
{
client_print(id, print_chat, "You're XP is too high! Resetting to 0!");
p_data[id][P_XP] = 0;
}
// Save the XP
switch( g_DBType )
{
case DB_MYSQLX: MYSQLX_Save( id );
case DB_SQLITE: SQLITE_Save( id );
case DB_VAULT: NVAULT_Save( id );
}

return;
}[/small]
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Thu Dec 14, 2006 5:34 pm

I will try this and tell you if this work...
But I think then this code should be diffrend:

[small]
// Save the user's XP
public DB_SaveXP( id )
{

if ( id >= TASK_SAVE )
{
id -= TASK_SAVE;
}

if ( !WC3_Check() )
{
return;
}

new iRaceID = p_data[id][P_RACE];

if ( iRaceID == 0 || !get_pcvar_num( CVAR_wc3_save_xp ) || p_data[id][P_XP] == 0 )
{
return;
}

// Allow bot's XP to be saved if we're saving by name
if ( is_user_bot( id ) && get_pcvar_num( CVAR_wc3_save_by ) != DB_SAVEBY_NAME )
{
return;
}

// We don't want to save their XP if they cheated and got level 10!!!
if ( g_bGivenLevel10[id][iRaceID] )
{
return;
}


if ( p_data[id][P_XP] > 100000 )
{
client_print(id, print_chat, "You're XP is too high! Resetting to 0!");
p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;
}
// Save the XP
switch( g_DBType )
{
case DB_MYSQLX: MYSQLX_Save( id );
case DB_SQLITE: SQLITE_Save( id );
case DB_VAULT: NVAULT_Save( id );
}

return;
}
[/small]

.... We will see .... thanks anyway
Last edited by Ufol on Sat Dec 16, 2006 10:32 am, edited 1 time in total.

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Thu Dec 14, 2006 7:26 pm

This code what you give me don't work or this is for other wersion then WC3:FT v2.3.2 .
Can you help me anyway ?
I'm quite sure then modyfikate code of Xp_Reset(id) in XP.inl and put some command in warcraft3FT.sma can help to reset xp when someone have 10000.
Modification of this code is smply i think:
[small]
// Reset the user's XP to 0
public XP_Reset(id)
{
#if ADVANCED_DEBUG
writeDebugInfo("XP_Reset", id);
#endif

if (!warcraft3)
return PLUGIN_CONTINUE;

p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

XP_Save(id);

WAR3_Display_Level(id, DISPLAYLEVEL_NONE);

client_print(id, print_chat, "%s %L", g_MODclient, id, "YOUR_XP_HAS_BEEN_RESET");

return PLUGIN_CONTINUE;
}
[/small]
change id:
[small]
// Reset the user's XP to 0 ...
public XP_Resett(id)
{
p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

XP_Save(id);

WAR3_Display_Level(id, DISPLAYLEVEL_NONE);

client_print(id, print_chat, "%s %L", g_MODclient, id, "YOUR_XP_HAS_BEEN_RESET");

return PLUGIN_CONTINUE;
}
[/small]
This is simply reset the xp and lvl ... We must only put some code now in warcraft3FT.sma for example when client connect that will run the "XP_Resett" if
"if ( p_data[id][P_XP] > 100000 )" - plz tell me how to do that ? and tell me if I'm wrong ?
I try to find solutions to my small problem
:(
Last edited by Ufol on Sat Dec 16, 2006 10:33 am, edited 2 times in total.

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Fri Dec 15, 2006 8:00 pm

The code I gave you is for 3.0...

and pls format your code using [small] tags...
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Sat Dec 16, 2006 10:34 am

As you wish :).

Geesu could you help me with version what i use ?? plz very ! - War3ft Version: WC3:FT v2.3.2

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Sun Dec 17, 2006 11:52 am

Post the savexp function that is in ur code...
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Wed Jan 03, 2007 5:24 pm

Geesu my code is not finish, plz help me ...
How I can use my idea in practise ?

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Post by YamiKaitou » Wed Jan 03, 2007 5:40 pm

[small]public XP_Save(id){
#if ADVANCED_DEBUG
writeDebugInfo("XP_Save",id)
#endif

if ( !warcraft3 )
{
return PLUGIN_CONTINUE;
}

if ( p_data[id][P_RACE] == 0 || is_user_bot(id) || !iCvar[MP_SAVEXP] || p_data[id][P_XP] == 0 )
{
return PLUGIN_CONTINUE;
}

// If we're saving by STEAM_ID, lets make sure the user has a steam ID
new szPlayerID[33];
get_user_authid(id, szPlayerID, 31);
if( iCvar[FT_SAVEBY] == 0 && equal(szPlayerID, "STEAM_ID_PENDING") )
{
return PLUGIN_CONTINUE;
}

//Added by YamiKaitou
//Resets everything to 0 if the xp is over 100000
if ( p_data[id][P_XP] > 100000 ) {
p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

client_print(id, print_chat, "%s Your XP has reached 100000 and has been reset", g_MODclient);
return PLUGIN_CONTINUE;
}


new szPlayerIP[20], szPlayerName[66];
get_user_name(id, szPlayerName, 32);
get_user_ip(id, szPlayerIP, 19);

// Save to the database
if ( iCvar[SV_SQL] )
{
// Verify we have a database connection
if ( !XP_Check_Connection() )
{
return PLUGIN_CONTINUE;
}

// Prepare name for the query (playername is 66 in case all 33 characters are ')
XP_AddSlashes( szPlayerName, 65 );

// Save the data
new szQuery[512];
format(szQuery, 511, "REPLACE INTO `%s` (`playerid`, `playername`, `xp`, `race`, `skill1`, `skill2`, `skill3`, `skill4`) VALUES ('%s', '%s', %d, %d, %d, %d, %d, %d)", g_DBTableName, (iCvar[FT_SAVEBY]==2) ? szPlayerName : ((iCvar[FT_SAVEBY]==1) ? szPlayerIP : szPlayerID), szPlayerName, p_data[id][P_XP], p_data[id][P_RACE], p_data[id][P_SKILL1], p_data[id][P_SKILL2], p_data[id][P_SKILL3], p_data[id][P_ULTIMATE]);

new Result:res = dbi_query(sql, szQuery);

// Verify we have a result
if (res < RESULT_NONE)
{
client_print(id, print_chat, "%s An error has occurred when saving your race information, please contact a server administrator", g_MODclient);
XP_DBI_Error( res, szQuery, 3 );
return PLUGIN_CONTINUE;
}
}
// Otherwise lets save to the vault
else
{
new szKey[128], szData[512];

// Format the data for entry
format( szData, 511, "%s %d %d %d %d %d %d %s %d %s", szPlayerID, p_data[id][P_XP], p_data[id][P_RACE], p_data[id][P_SKILL1], p_data[id][P_SKILL2], p_data[id][P_SKILL3], p_data[id][P_ULTIMATE], szPlayerIP, get_systime(), szPlayerName );

// Format the vault key
format( szKey, 127, "%s_%d", (iCvar[FT_SAVEBY]==SAVE_NAME) ? szPlayerName : ((iCvar[FT_SAVEBY]==SAVE_IP) ? szPlayerIP : szPlayerID), p_data[id][P_RACE] );

// Save the data
set_vaultdata(szKey, szData);
}

return PLUGIN_CONTINUE
}[/small]


In your XP.inl file, replace the entire XP_Save function with this and recomplile. Not sure if this will work. Just made this up in about a minute. Let me know if it works.
Last edited by YamiKaitou on Thu Jan 04, 2007 12:23 am, edited 2 times in total.
Image

No support via PM or Email

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Wed Jan 03, 2007 8:21 pm

Yami - after:

[small]client_print(id, print_chat, "%s Your XP has reached 100000 and has been reset", g_MODclient); [/small]

You need to have:

return;
}
No Support via PM

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Post by YamiKaitou » Wed Jan 03, 2007 8:42 pm

Oh, opps. I havn't done this in a bit. I have been doing php mostly now. Fixed the post

EDIT: Now that looks a little wierd. Returning nothing?
Image

No support via PM or Email

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Thu Jan 04, 2007 12:20 am

lols PLUGIN_CONTINUE
No Support via PM

Ufol
Peon
Posts: 9
Joined: Wed Dec 13, 2006 7:17 am

Post by Ufol » Fri Jan 12, 2007 2:47 am

[small]//Resets everything to 0 if the xp is over 150000
if ( p_data[id][P_XP] > 150000 ) {
p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

WAR3_Display_Level(id, DISPLAYLEVEL_NONE);

client_print(id, print_chat, "%s %L", g_MODclient, id, "Your XP has reached 150000 and has been reset");
return PLUGIN_CONTINUE
}
[/small]

I correct your code, And My FRIEND This time it WORK VERY WELL !!

THANk'S FOR ALL YOUR HELP !!

THIS CODE IS FOR VERSION: WC3:FT v2.3.2

And The all Instruction to do this:
In the Xp.inl find :
[small]
public XP_Save(id){
#if ADVANCED_DEBUG
writeDebugInfo("XP_Save",id)
#endif

if ( !warcraft3 )
{
return PLUGIN_CONTINUE;
}

if ( p_data[id][P_RACE] == 0 || is_user_bot(id) || !iCvar[MP_SAVEXP] || p_data[id][P_XP] == 0 )
{
return PLUGIN_CONTINUE;
}

// If we're saving by STEAM_ID, lets make sure the user has a steam ID
new szPlayerID[33];
get_user_authid(id, szPlayerID, 31);
if( iCvar[FT_SAVEBY] == 0 && equal(szPlayerID, "STEAM_ID_PENDING") )
{
return PLUGIN_CONTINUE;
}

new szPlayerIP[20], szPlayerName[66];
get_user_name(id, szPlayerName, 32);
get_user_ip(id, szPlayerIP, 19);

[/small]

Then Replace it This Code:

[small]
public XP_Save(id){
#if ADVANCED_DEBUG
writeDebugInfo("XP_Save",id)
#endif

if ( !warcraft3 )
{
return PLUGIN_CONTINUE;
}

if ( p_data[id][P_RACE] == 0 || is_user_bot(id) || !iCvar[MP_SAVEXP] || p_data[id][P_XP] == 0 )
{
return PLUGIN_CONTINUE;
}

// If we're saving by STEAM_ID, lets make sure the user has a steam ID
new szPlayerID[33];
get_user_authid(id, szPlayerID, 31);
if( iCvar[FT_SAVEBY] == 0 && equal(szPlayerID, "STEAM_ID_PENDING") )
{
return PLUGIN_CONTINUE;
}

//Resets everything to 0 if the xp is over 150000
if ( p_data[id][P_XP] > 150000 ) {
p_data[id][P_LEVEL] = 0;
p_data[id][P_XP] = 0;
p_data[id][P_SKILL1] = 0;
p_data[id][P_SKILL2] = 0;
p_data[id][P_SKILL3] = 0;
p_data[id][P_ULTIMATE] = 0;

WAR3_Display_Level(id, DISPLAYLEVEL_NONE);

client_print(id, print_chat, "%s %L", g_MODclient, id, "Your XP has reached 150000 and has been reset");
return PLUGIN_CONTINUE
}

new szPlayerIP[20], szPlayerName[66];
get_user_name(id, szPlayerName, 32);
get_user_ip(id, szPlayerIP, 19);
[/small]

You can set your own level of XP to reset.

Big Thanks Again !

And offcourse compile plugin of war3ft ...

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Post by YamiKaitou » Fri Jan 12, 2007 2:52 am

Not a problem. Glad we could help you
Image

No support via PM or Email

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Tue Feb 19, 2008 12:00 pm

XP management is entirely different in 3.0 vs. 2.3.2

Search for DB_Save function in db.inl
No Support via PM

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Wed Feb 20, 2008 12:44 pm

Yea I re-wrote everything :P
No Support via PM

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Fri Feb 22, 2008 10:29 am

I think I should leave that to the server owner to run a cron job :P
No Support via PM

User avatar
Geesu
<b>King of the world!</b>
Posts: 3159
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Post by Geesu » Wed Feb 27, 2008 11:19 am

add it as a request in flyspray (bug reporting link)
No Support via PM

Post Reply