Blockland Forums > Modification Help
Points Value [Solved by Port]
Port:
--- Quote from: jes00 on January 29, 2012, 09:50:30 PM ---This only gives me the value of the first player's score.
--- End quote ---
Yes, you forgot to change index.
--- Quote from: Nitramtj on January 29, 2012, 10:33:51 PM ---"index" is a number from 0 - (playerCount - 1), not a name.
--- End quote ---
jes00:
--- Quote from: Port on January 30, 2012, 02:50:41 AM ---Yes, you forgot to change index.
--- End quote ---
No, I changed it to %name.
--- Quote from: Nitramtj on January 29, 2012, 10:33:51 PM ---"index" is a number from 0 - (playerCount - 1), not a name.
--- End quote ---
Then how can I have it search for a string instead?
Port:
--- Code: ---function getPlayerScore( %name )
{
%count = NPL_List.rowCount();
for ( %i = 0 ; %i < %count ; %i++ )
{
%row = NPL_List.getRowText( %i );
if ( getField( %row, 1 ) $= %name )
{
return getField( %row, 2 );
}
}
return 0;
}
--- End code ---
jes00:
--- Quote from: Port on January 30, 2012, 06:41:34 AM ---
--- Code: ---function getPlayerScore( %name )
{
%count = NPL_List.rowCount();
for ( %i = 0 ; %i < %count ; %i++ )
{
%row = NPL_List.getRowText( %i );
if ( getField( %row, 1 ) $= %name )
{
return getField( %row, 2 );
}
}
return 0;
}
--- End code ---
--- End quote ---
Thanks Port!
EDIT: What are the returns for?
Port:
--- Quote from: jes00 on January 30, 2012, 07:35:46 AM ---EDIT: What are the returns for?
--- End quote ---
They return the value found..?