Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Sorting players with their cash (https://forums.graalonline.com/forums/showthread.php?t=79877)

Stryke 05-30-2008 06:37 PM

What's the difference between these two?
 
PHP Code:

temp.var1 = array[b];
temp.var2 = list[b];
temp.var3 blol[b];
temp.var4 blob[b];
        
array[
b] = array[b+1];
list[
b] = list[b+1];
blol[b] = array[b+1];
blob[b] = list[b+1];
        
array[
b+1] = temp.var1;
list[
b+1] = temp.var2;
blol[b+1] = temp.var3;
blob[b+1] = temp.var4

PHP Code:

for(05c++;)
{
  
makevar("temp.var" 1) = params[b];
  
temp.pm params[c];
  
temp.pm[c] = temp.pm[c+1];
  
temp.pm[c+1] = makevar("temp.var" 1);


What's the difference between these two?
If I replace them why won't it work?

Chompy 06-01-2008 03:09 AM

Uhm, in the second, the loop is running one time more then it should (will produce a var5)

In your first example you first set all the var# to array[b], list[b], blol[b] and blob[b], but in your second example they're all params[b], and then you suddenly use 'temp.pm'(params[c]) in the second example when it should be params[b].. I'm not going to continue explaining since the examples uses different variables, but in the end, they're not equal..

What is b? Why does params[] represent array[], list[], blol[] and blob[]?

You need to show better examples or word your question better :o

Stryke 06-01-2008 09:21 PM

The function used:

SortPlayers( array , list , blol , blob);

params[0] = array.
params[1] = list.
params[2] = blol.
params[3] = blob.

Oops at : makevar("temp.var" @ c + 1) = params[b];
That should be params[3].

Here's the full code tell me what you see is different:

PHP Code:

function SortPlayers( list , array , bol blob )
{
  
temp.result "";
  for(
0< array.size() - 1++;)
  {
    for(
0< array.size() - 1++;)
    {
      if(array[
b] < array[b+1])
      {
        for(
04c++;) 
        { 
          
makevar("temp.var" 1) = makevar(params[c]@"["@(b)@"]");
          
makevar(params[c]@"["@(b)@"]") = makevar(params[c]@"["@(b+1)@"]");
          
makevar(params[c]@"["@(b+1)@"]") = makevar("temp.var" 1); 
        }  
      }
    }
  }
  return list;



Chompy 06-01-2008 09:40 PM

Quote:

Originally Posted by Stryke (Post 1393727)
Here's the full code tell me what you see is different:

PHP Code:

... 


But why do you need to see the difference? Doesn't yours work? Does it work?

And, is this for something like a score system? It records who has the most money on the server etc.?

[email protected] 06-01-2008 11:25 PM

HTML Code:

function onCreated() {
  for (temp.i: allplayers)
    temp.accs.add({i, i.rupees});
   
  for (i: accs) {
    temp.e.add(i[0]);
    temp.e[temp.c].sortvalue = i[1];
    temp.c++;
  }
  e.sortbyvalue("sortvalue", "float", false);
 
  for (i = 0; i < accs.size(); i++)
    echo(e[i] SPC e[i].rupees);

should do it


All times are GMT +2. The time now is 03:18 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.