Jump to content

Nerks

Members
  • Posts

    135
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Nerks

  1. On 11/16/2017 at 6:37 PM, Scanty said:

    Are you using the official Endless Tower right?

    Or you just edit some code?

    Show me your instance_db. Located in your pre-re folder if you use pre-renewal system or "re" folder.

    You try to use another Endless Tower script, maybe?

    Yes,I'm using official Endless Tower i download it on github of Rathena.

    May i request for a new Endless Tower.

  2. 12 hours ago, Skorm said:

    It took me a bit to understand dynamic shops when I was first learning too. This is the npc I used to understand dynamic shops but I added a bunch of comments hopefully it helps. ( Disclaimer: This npc is old and doesn't have all the necessary weight checks and mumbo-jumbo I'm providing it as an example because it's simple. )
     

    -	shop	custom_seller2	-1,501:20 // Create our dummy shop.
    
    
    prontera.gat,95,99,5	script	WoE Shop	100,{
    	
    // This code runs when the user clicks our npc.
    	mes "I will sell you items for " + getitemname(.CoinID) + "."; // Let the user know about our shop.
    	
    	callshop "custom_seller2",1; // Summon our dummy shop filled with custom items.
    	
    	npcshopattach "custom_seller2"; // Attach the shop to this npc.
    	
    	end;
    
    // This code runs when a user purchases an item from out shop.
    OnBuyItem:
    	.@len = getarraysize(.customs); // Get the number of customs we're adding.
    	.@b_len = getarraysize(@bought_nameid); // Get the number of purchased items.
    
    	for( set @i, 0; @i < .@len; set @i, @i+1 ) {
    		for( set @d,0; @d < .@b_len; set @d, @d+1 ) {
    			if( @bought_nameid[@d] == .customs[@i] ) { // Check if the purchased item equals our custom item.
    				if( countitem(.CoinID) >= .Price[@i] * @bought_quantity[@d] ) { // Check if the user has the correct funds.
    					delitem .CoinID,.Price[@i]*@bought_quantity[@d];
    					getitem @bought_nameid[@d],@bought_quantity[@d];
    				}
    			}
    		}
    	}
    	deletearray @bought_quantity, getarraysize(@bought_quantity); // Remove the array.
    	deletearray @bought_nameid, getarraysize(@bought_nameid); // Remove the array.
    	close;
    
    // This code runs first. When the server is started.
    OnInit:
    	setarray .customs[0],12103,607,678; // An array of out custom items.
    	
    	set .CoinID,7227; // Currency used for the transaction.
    	
    	setarray .Price[0],20,40,300; // The amount of coins needed for our items. (For example: Item 12103 = 20 coins)
    	
    	npcshopitem "custom_seller2",0,0; // Remove all items from our dummy shop.
    	
    	for( set .@i, 0; .customs[.@i]; set .@i, .@i+1 ) // Loop through our custom items.
    		npcshopadditem "custom_seller2",.customs[.@i],.Price[.@i]; // Add our custom items to the cleared dummy shop.
    	
    	end;
    }

     

    Thank you so much @Skorm

  3. On 8/2/2017 at 11:04 PM, Z3R0 said:

    Crude and Highly Untested

    prontera,158,173,4	script	CoinExchanger	88,{
    
    	mes("Welcome");
    	mes("Please give me your coins...");
    	
    	// Check Inventory for Coins
    	getinventorylist;
    
    	freeloop(true);
    	for([email protected]_index = 0; [email protected]_index < getarraysize(.exchange_ids); [email protected]_index++) {
    		for([email protected] = 0; [email protected] < @inventorylist_count, [email protected]++) {
    			if (@inventorylist_id[[email protected]] == .exchange_ids[[email protected]_index]) {
    				if (@inventorylist_amount[[email protected]] >= .exchange_amount[[email protected]_index]) {
    					set([email protected]_coin_index[getarraysize([email protected]_coin_index)], [email protected]_index);
    					set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");
    				}
    			}
    		}
    	}
    	freeloop(false);
    
    	// Display Option to Show them choices and how many coins they have...
    	set [email protected], select([email protected]$) - 1; // Subtract 1 to get Array Index
    	set [email protected], [email protected]_coin_index[[email protected]];
    
    	dispbottom("You have chosen to use " + getitemname(.exchange_ids[[email protected]]) );
    
    	progressbar("00FF00", .exchange_duration[[email protected]]); // Start the Progressbar 
    
    	// On Progress Bar Completion... let's see what we do here...
    	delitem(.exchange_ids[[email protected]], .exchange_amount[[email protected]];
    	freeloop(true);
    	for([email protected] = 0; [email protected] < getarraysize(.available_items); [email protected]++) {
    		[email protected] = rand(1, 100); 
    		if ([email protected] <= .available_chance[[email protected]]) { // GET THE ITEM
    			mes "Here you go";
    			getitem(.available_items[[email protected]], .available_amount[[email protected]]);
    			if (.available_chance[[email protected]] <= .announce_level_chance) {
    				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[[email protected]]), bc_all, C_YELLOW);
    			}
    			close;
    		} 
    	}
    	freeloop(false);
    
    	mes("You got the default prize...");
    	getitem(.default_item, .default_amount);
    	close;	
     
    	OnInit:
    		setarray(.exchange_ids, 673, 675, 671, 677);
    		setarray(.exchange_amount, 1, 1, 1, 1);
    		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...
    
    		setarray(.available_items, 501, 502, 503, 504);
    		setarray(.available_amount, 1, 1, 1, 1);
    		setarray(.available_chance, 50, 40, 30, 10); // % of 100 
    
    		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
    		
    		set(.default_item, 501);
    		set(.default_amount, 1);
    		end;
    
    }

     

    @Z3R0 may i ask a question.

    what is the "?" all about on this code

    set([email protected]$, ( [email protected]$ = "" ? "" : ":" ) + getitemname(.exchange_ids[[email protected]_index]) + "(" + @inventorylist_amount[[email protected]] + ")");

  4. 1 hour ago, Skorm said:

    You only need escape_sql when dealing with string variables.

    [email protected] is a integer variable so nobody can put an escape character like "; or something to cause harm to your database.

    if the variable was [email protected]$ and a user put text for that [email protected]$ variable like '; DROP TABLE `accounts`;

    MySQL would read

    select `field` from `table` where `field` = ''; DROP TABLE `accounts`;

     

    Now i get it. even on my EXAMPLE 1 i need to put escape_sql.

    It's more safer to you use escape_sql on every variable.

    little code MAXIMUM Effects /no1

  5. 4 hours ago, Skorm said:
    '"[email protected]$+"'

    It's not double quotes like you have. It's quotes ( " ) then single quotes ( ' ). The single quotes are for SQL to be like OK this is a string. Normal Quotes are there to break the string server side.

    So what it's doing

    "String '(Start SQL String) (Break NPC Compiler String)"+(.@npc_string_variable$)+"(Enter NPC String) (End SQL String)' (End NPC String)"

     

    Sorry for the confusion on my question.

    im about to ask is the difference of this two(2).

    EXAMPLE 1:

    query_sql "select `field` from `table` where `field` = " + [email protected], holder;

    Question on EXAMPLE 1, do i need to put escape_sql() on the [email protected] even its outside of double qoute (")

     

    CORRECT USAGE:

    EXAMPLE 2:

    query_sql "select `field` from `table` where `field` = '" + escape_sql([email protected]) + "'";

    This EXAMPLE 2 is commonly use each one of us..

     

  6. 1 hour ago, llchrisll said:

    Escape_sql() is only required for text inputs, like WHERE `char_name` = '"+escape_sql([email protected]$)+"'";

    In the ( ) comes the text/variable/array.

    Regards,

    Chris

    Thanks for the answer.

    back to my question.. how about outside of double qoute("") on query sql just like my sample is it necessary?

  7. 1 hour ago, Haruka Mayumi said:

    It's possible for users to DROP or edit something on your database using a script like you want(though it depends on the script).. =)

    Do i need to use the escape_sql() inside the query_sql " ";

    Cause sometimes i use like this:

    query_sql "select `id` from `table` where `id` = " + [email protected];

    Do i need to use escape_sql() on the [email protected] or just leave it like that because it is outside of the ""(double qoute)?

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.