AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Inc (https://forums.alliedmods.net/showthread.php?t=143746)

ProIcons 11-24-2010 10:34

Inc
 
PHP Code:

new TeamAScore[3];
new 
TeamBScore[3];
new 
TeamAHalfA[3];
new 
TeamAHalfB[3];
new 
TeamBHalfA[3];
new 
TeamBHalfB[3];

public 
asd() {
[
95]      TeamBScore += 1;
[
94]      TeamBHalfA += 1;
            return 
PLUGIN_HANDLED
}
public 
asd2() {
[
114]     TeamBScore ++;
[
115]     TeamBHalfA ++;
            return 
PLUGIN_HANDLED


Quote:

Error: Array assignment must be simple assignment on line 95
Warning: Expression has no effect on line 95
Error: Array assignment must be simple assignment on line 96
Warning: Expression has no effect on line 96
Error: Must be lvalue (non-constant) on line 114
Error: Must be lvalue (non-constant) on line 115
I Can do it with other way but i don't remember how :P i have forgot :P

shadow.hk 11-24-2010 13:43

Re: Inc
 
PHP Code:

public asdnum )
{
     for( new 
03i++ )
     {
          
TeamBScore] += num;
          
TeamBHalfA] += num;
     }


?

ProIcons 11-24-2010 15:05

Re: Inc
 
:/
actually i want The Variable to be just one value... :/
a team score

Exolent[jNr] 11-24-2010 16:08

Re: Inc
 
Quote:

Originally Posted by ProIcons (Post 1355875)
:/
actually i want The Variable to be just one value... :/
a team score

Then why did you make arrays?

Quote:

Originally Posted by ProIcons (Post 1355700)
PHP Code:

new TeamAScore[3];
new 
TeamBScore[3]; 



ProIcons 11-24-2010 16:20

Re: Inc
 
well after posting this post, i was wondering the same thing xD. if i will do it index variable, i will be able to set it like this:

var = 1;
var = "asd";
var ++;
etc ?:P

Exolent[jNr] 11-24-2010 16:36

Re: Inc
 
You can only set an array to another array of equal or lesser size.
You can't mix dimensions.

Code:
new var; // 0 dimensions new var2[10]; // 1 dimension new var3[10][10]; // 2 dimensions // etc. var = var2; // invalid (var=0dim, var2=1dim) var = var3; // invalid (var=0dim, var3=2dim) var2 = var; // invalid (var2=1dim, var=0dim) var2 = var3; // invalid (var2=1dim, var3=2dim) var3 = var; // invalid (var3=2dim, var=0dim) var3 = var2; // invalid (var3=2dim, var2=1dim)

When you index an array, you remove 1 dimension.

Code:
var = var2[0]; // valid (var=0dim, var2[0]=0dim) var = var3[0][0]; // valid (var=0dim, var3[0][0]=0dim) var2[0] = var; // valid (var2[0]=0dim, var=0dim) var2 = var3[0]; // valid (var2=1dim, var3[0]=1dim) var2[0] = var3[0][0]; // valid (var2[0]=0dim, var3[0][0]=0dim) var3[0] = var2; // valid (var3[0]=1dim, var2=1dim) var3[0][0] = var; // valid (var3[0][0]=0dim, var=0dim) var3[0][0] = var2[0]; // valid (var3[0][0]=0dim, var2[0]=0dim)

Examples:
Code:
new iPlayers[32]; // iPlayers is 1dim array //get_players()... new iPlayer = iPlayers[0]; // iPlayer is 0dim variable, iPlayers[0] gets a 0dim variable because it removes 1 dimension.
Code:
new szNames[33][32]; // array of all player name arrays = 2dim new szName[32]; // player name array = 1dim szName = szNames[0]; // szName=1dim, szNames[0]=1dim because it is indexes so 1 dimension is removed

ProIcons 11-24-2010 16:57

Re: Inc
 
how can i add a value to an index var..? format(TeamBScore,2,"asd"); ? Something like this..

Exolent[jNr] 11-24-2010 17:01

Re: Inc
 
You can't mix integers and strings.
What are you trying to do?

ProIcons 11-25-2010 03:01

Re: Inc
 
Actually i am trying to
set a team score example:

TeamAScore = 0;

TO reset it. and after that every round end to Inc it... but after that i want to check somehow this values

Example
PHP Code:

if (equali(TeamBScore,"16")) {
            
msg("Match is Finished. Team Beta Won");
        }
        if (
equali(TeamAScore,"16")) {
            
msg("Match is Finished. Team Alpha Won");
        }
if( (
equali(TeamBScore,"15")) && (equali(TeamAScore,"15")) {
            
msg("Match is Finished. Team Are Draw");
        } 


Exolent[jNr] 11-25-2010 03:55

Re: Inc
 
Code:
if(TeamAScore == 16)


All times are GMT -4. The time now is 11:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.