Register for your free account! | Forgot your password?

You last visited: Today at 23:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[RELEASE]PHP Scripts

Discussion on [RELEASE]PHP Scripts within the Shaiya PServer Guides & Releases forum part of the Shaiya Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
[RELEASE]PHP Scripts

Here are php scripts which people might find useful.
1. PVP Rankings - It shows the top 25 players in the server in order of kills
2. UM Res - Allows users to rez dead UM toons

I'll add more scripts as I make them.If you have any feedback post here

UPDATE1 : Char-res improved (new approach)
UPDATE2: Char-res, now easier with more than 1 toon with same name
Attached Files
File Type: zip scripts.zip (33.9 KB, 2571 views)
zargon05 is offline  
Thanks
15 Users
Old 01/08/2011, 09:11   #2
 
abrasive's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
I only looked at the res script so far and I noticed you can cut out some duplicate code and cut down the queries by one by changing this:
Code:
	if($slot[0]>-1 && $slot[0]<5)
	{
		$res3 = mssql_query("SELECT * FROM [dbo].[UserMaxGrow] WHERE UserUID IN (SELECT UserUID FROM dbo.Chars WHERE UserID='$login')");
		$country = mssql_fetch_array($res3);
		if ( $country['Country'] == 0 ) {
			$res4 = mssql_query("SELECT family FROM [dbo].[Chars] WHERE charname='$toon'");
			$family =  mssql_fetch_array($res4);
			echo "Family = $family[0] <br />";
			if ( $family[0] == 0 || $family[0] == 1)
			{
				mssql_query("UPDATE dbo.Chars SET Del=0, Slot=$slot[0] , Map=42 , PosX=63 , PosZ=57 , DeleteDate=NULL WHERE CharName = '$toon'");
				echo "$toon was successfully resurrected</font>";
			}
			else 
			echo "Faction Error: Cannot ressurect UoF toon on AoL";
		}
		else if( $country['Country'] == 1) {
		
			$res4 = mssql_query("SELECT family FROM [dbo].[Chars] WHERE charname='$toon'");
			$family =  mssql_fetch_array($res4);
			if ( $family[0] == 2 || $family[0] == 3)
			{
				mssql_query("UPDATE dbo.Chars SET Del=0, Slot=$slot[0] , Map=42 , PosX=63 , PosZ=57 , DeleteDate=NULL WHERE CharName = '$toon'");
				echo "$toon was successfully resurrected</font>";
			}
			else 
			echo "Faction Error: Cannot ressurect AoL toon on UoF";
		}
		else
		echo "Faction error";
	}
	else
	echo "No slot avaliable";
To something like this:
Code:
	if($slot[0]>-1 && $slot[0]<5){
		$res3 = mssql_query("SELECT umg.Country, c.Family FROM [dbo].[UserMaxGrow] AS umg INNER JOIN [dbo].[Chars] AS c ON umg.UserUID = c.UserUID WHERE c.UserID = '$login' AND c.CharName = '$toon'");
		$result =  mssql_fetch_array($res3);
		if($result['Country'] == 0 || $result['Country'] == 1){
			if($result['Family'] >= 0 && $result['Family'] <= 3){
				mssql_query("UPDATE dbo.Chars SET Del=0, Slot=$slot[0], Map=42, PosX=63 , PosZ=57, DeleteDate=NULL WHERE CharName = '$toon'");
				echo "$toon was successfully resurrected</font>";
			}else{
				if($result['Family'] == 0 || $result['Family'] == 1){
					echo "Faction Error: Cannot ressurect UoF toon on AoL";
				}else if($result['Family'] == 2 || $result['Family'] == 3){
					echo "Faction Error: Cannot ressurect AoL toon on UoF";
				}
			}
		}else{
			echo "Faction error";
		}
	}else{
		echo "No slot available";
	}
Generally it is considered bad practice to use SELECT *, because you are returning more data than you are actually using, unless you are using ALL columns. It is better to specifically ask for the columns you want.

I would suggest using joins instead of sub queries when possible as well. Take a look at my $res3 query as an example.

Also I would use dictionary indexes instead of array indexes when asking for data from query results, otherwise you are asking for trouble if the order ever changes.

How come you chose to echo some of the html, but not all of it, or vice versa?

Overall the res script looks good. It also appears to be secure also which is the most important part. I didn't actually test anything though, just browsed through the script.
abrasive is offline  
Thanks
9 Users
Old 01/08/2011, 17:17   #3
 
elite*gold: 0
Join Date: Dec 2010
Posts: 8
Received Thanks: 0
gratz!

Great Job! Thank you : )
Catafalque is offline  
Old 01/08/2011, 22:56   #4
 
Bаne's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 2,334
Received Thanks: 1,777
# added to my guide. good job to both of you

-Bane
Bаne is offline  
Old 01/09/2011, 17:47   #5
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
@ Abrasive

I haven't read into the original script but your optimization will do the same what I had problem with. Meaning my first UM resurrection script resurrected an AoL character on UoF side. You need to check for Country separately with extra checks for Family. Players can change sides if they loose all of their characters.

Country=2 is only when all characters are dead. It means Faction Selection screen.

EDIT:
Here's my solution to this problem:

Code:
IF (SELECT Country FROM PS_GameData.dbo.UserMaxGrow WHERE UserUID=@UserUID)<>2
begin
	PRINT 'Player chose faction after loosing all characters. Checking whether new characters exist.'
		-- let's get that new faction and see if it's the same as the last time
	SELECT @Country=Country FROM PS_GameData.dbo.UserMaxGrow WHERE UserUID=@UserUID
	
	IF EXISTS (SELECT * FROM PS_GameData.dbo.Chars WHERE UserUID=@UserUID AND Del=0)
	begin
		PRINT 'Player has new characters. Checking faction.'
		PRINT '----------'
		
		IF (@Family=0 OR @Family=1) AND @Country<>0
		begin
			-- Faction is not the same. Was Alliance of Light is Union of Fury. Character not resurrected.										
			
			INSERT INTO @ResultTable 
				(CharID, CharName, Resurrected, NoFreeSlots, FactionChange) 
			VALUES
				(@CharID, @CharName, 'no', 'no', 'yes');
			FETCH NEXT FROM dead_um INTO
				@UserUID,@CharID,@Slot,@CharName,@Family																										
			
			CONTINUE;
		end
		ELSE IF (@Family=2 OR @Family=3) AND @Country<>1
		begin
			-- Faction is not the same. Was Union of Fury is Alliance of Light. Character not resurrected.
			
			INSERT INTO @ResultTable
				(CharID, CharName, Resurrected, NoFreeSlots, FactionChange) 
			VALUES
				(@CharID, @CharName, 'no', 'no', 'yes');
			FETCH NEXT FROM dead_um INTO
				@UserUID,@CharID,@Slot,@CharName,@Family																										
			
			CONTINUE;										
		end																
	end
	ELSE
	begin
		PRINT 'No new characters detected. Proceeding with standard routine.'
		PRINT '----------'
	end						
end
ProfNerwosol is offline  
Thanks
2 Users
Old 01/09/2011, 19:03   #6
 
abrasive's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
Quote:
Originally Posted by ProfNerwosol View Post
@ Abrasive

I haven't read into the original script but your optimization will do the same what I had problem with. Meaning my first UM resurrection script resurrected an AoL character on UoF side. You need to check for Country separately with extra checks for Family. Players can change sides if they loose all of their characters.

Country=2 is only when all characters are dead. It means Faction Selection screen.
Thanks, I didn't catch that logic when I was optimizing. Zargon pm'ed me about it too.

Since both are running identical code, you could make the error message more generic and do it kind of like this:
Code:
if($slot[0]>-1 && $slot[0]<5){
	$res3 = mssql_query("SELECT umg.Country, c.Family FROM [dbo].[UserMaxGrow] AS umg INNER JOIN [dbo].[Chars] AS c ON umg.UserUID = c.UserUID WHERE c.UserID = '$login' AND c.CharName = '$toon'");
	$result =  mssql_fetch_array($res3);
	if(
		($result['Country'] != 0 && ($result['Family'] == 0 || $result['Family'] == 1)) ||
		($result['Country'] != 1 && ($result['Family'] == 2 || $result['Family'] == 3)) 
	){
		echo "Faction Error: Cannot ressurect toon into the opposite faction of which they were born into.";
	}else{
		mssql_query("UPDATE dbo.Chars SET Del=0, Slot=$slot[0], Map=42, PosX=63 , PosZ=57, DeleteDate=NULL WHERE CharName = '$toon'");
		echo "$toon was successfully resurrected</font>";
	}
}else{
	echo "No slot available";
}
Apparently Zargon is unable to use the dictionary indexes. I know that when I rewrote this script the dictionary indexes worked for me, so I'm unsure why he would have problems with them.
abrasive is offline  
Thanks
1 User
Old 01/10/2011, 08:57   #7
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
I made a new approch since abrasive's post, now toons that are in opposing faction are not dispalyed/avaliable to ressurection. I also forgot about more than 1 toon with same name so I am going to make a work-around. The dictionary index work when I use SELECT * but when I use JOINS it displays undefined index. I am going to try and fix this.
zargon05 is offline  
Thanks
1 User
Old 01/23/2011, 03:43   #8
 
elite*gold: 0
Join Date: Dec 2010
Posts: 8
Received Thanks: 0
Char-res not working. Toon not ressing.
Catafalque is offline  
Old 01/23/2011, 04:36   #9
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
I just downloaded and tested it and works perfectly in my DB. Do you get any error or it just does not res?
zargon05 is offline  
Old 01/24/2011, 13:59   #10
 
elite*gold: 0
Join Date: Dec 2010
Posts: 8
Received Thanks: 0
Quote:
Originally Posted by zargon05 View Post
I just downloaded and tested it and works perfectly in my DB. Do you get any error or it just does not res?
İ dont get any error. This script perfectly. But toon's not ressing. :P
Catafalque is offline  
Old 01/25/2011, 05:51   #11
 
elite*gold: 0
Join Date: Jan 2011
Posts: 53
Received Thanks: 9
Quote:
Originally Posted by Catafalque View Post
İ dont get any error. This script perfectly. But toon's not ressing. :P
I had to add RemainTime=0 in the query, not sure if anyone else has had to do this.
-Infamy- is offline  
Old 01/25/2011, 11:32   #12
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
Did you add it in character searching query? I was about to suggest it to avoid selecting characters which were deleted by user. RemainTime<>0 is delete requested by user.

Btw, the script works. I tested it on my database.
ProfNerwosol is offline  
Old 01/25/2011, 11:53   #13
 
elite*gold: 0
Join Date: Jan 2011
Posts: 53
Received Thanks: 9
I had to add it the the updating query at the end, it was reviving the characters only partially, although that was before the latest post, so I am not sure if he has added that or not.
-Infamy- is offline  
Old 01/25/2011, 19:55   #14
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
You shouldn't add RemainTime=0 in UPDATE statement. You will resurrect characters deleted by player this way. RemainTime=0 should be in WHERE clause in SELECT statement searching for player's dead characters.
ProfNerwosol is offline  
Old 01/31/2011, 23:04   #15
 
elite*gold: 0
Join Date: Jan 2011
Posts: 53
Received Thanks: 9
The character resurrection script allowed for someone to resurrect a light toon on the fury side. :x
-Infamy- is offline  
Reply


Similar Threads Similar Threads
[Release]Scripts,Hacks ...
09/19/2010 - Counter-Strike Hacks, Bots, Cheats & Exploits - 5 Replies
Heey leutz bin zwar neu hier und ich denke ihr werdet mir nicht vertrauen <.<, aber trotzdem Release ich ein paar Scripts und einen hack den ich kenne.Wer mir nicht vertraut virustotal.com ! Hoffe es kommen faire Comments und nicht irgend ein geflame weil ich neu bin =) Unter den Überschriften steht das HowTo! Scipts: Pingfake=
[PRE-RELEASE] easy translate scripts.
03/20/2010 - EO PServer Hosting - 11 Replies
hey, i have asked the question, and have got some reaction. So here it is. Not every thing is translated but most things you see are. (basic eudemons + basic monsters + basic guards) If you have some idea's for me that i also need to make a script for, feel free to ask :bandit: "example of script"
[Release] scripts
03/03/2010 - Dekaron Exploits, Hacks, Bots, Tools & Macros - 2 Replies
These are working cheat engine scripts ( i take no credit for creating them) I put the new offsets in them so just copy and paste into autoassembler. MOB SPEED: alloc(DrakoMobSpeed,64) label(MobIsWalking) label(ReturnMobSpeed) label(MobRunSpeed) label(MobWalkSpeed)
[Release] EMS 0.59 scripts
12/29/2009 - MapleStory - 1 Replies
Not posting a HS (CRC) Bypass, leech yourself one else where. All scripts WERE made or updated by me. No Knockback 007D52FF: jnl 007d5304
[RELEASE]Scripts for the stack eps.
09/08/2009 - EO PServer Guides & Releases - 34 Replies
well there was a release of stack eps lready but i'll be more clver and make it a lot easier for you ,because most of the server have different cq_itemtypes and cq_actions that's why i have decided to release the scripts for it so you dont have to change your cq_action. :):D :cool: Because there is no way to make any scripts for the itemtype.dat i have made one, this itemtype.dat is the latest one there is, it contains all the new pets form chinese database and everything else, of course it;s...



All times are GMT +2. The time now is 23:49.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.