New Variable in gamemodeinit?
#1

Heey all,
How can i put this:
Код:
	WeaponPrices[playerid][1]=5000;
	WeaponPrices[playerid][2]=10000;
	WeaponPrices[playerid][3]=10000;
	WeaponPrices[playerid][4]=13000;
	WeaponPrices[playerid][5]=8000;
	WeaponPrices[playerid][6]=12000;
	WeaponPrices[playerid][7]=15000;
	WeaponPrices[playerid][8]=15000;
	WeaponPrices[playerid][9]=14000;
	WeaponPrices[playerid][10]=14000;
	WeaponPrices[playerid][11]=15000;
	WeaponPrices[playerid][12]=1000;
Into gamemodeinit?

Thanks Admigo
Reply
#2

You can't as it contains a player variable.
Reply
#3

If it's for every player you can do:
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
{
    WeaponPrices[i][1]=5000;
    WeaponPrices[i][2]=10000;
    WeaponPrices[i][3]=10000;
    WeaponPrices[i][4]=13000;
    WeaponPrices[i][5]=8000;
    WeaponPrices[i][6]=12000;
    WeaponPrices[i][7]=15000;
    WeaponPrices[i][8]=15000;
    WeaponPrices[i][9]=14000;
    WeaponPrices[i][10]=14000;
    WeaponPrices[i][11]=15000;
    WeaponPrices[i][12]=1000;
}
Reply
#4

If initiating at the declaration is not possible (like in this case with a 2-dimensional array), you should just use a standard MAX_PLAYER loop in OnGameModeInit. Sometimes I see people do this, though:
pawn Код:
new SomeVar[MAX_PLAYERS];

public OnGameModeInit()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        SomeVar[i] = -1;
    }
    return 1;
}
That's bad. To initialize a single dimension array, you'd instead use:
pawn Код:
new SomeVar[MAX_PLAYERS] = {-1, ...};
Reply
#5

Quote:
Originally Posted by funky1234
Посмотреть сообщение
If it's for every player you can do:
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
{
    WeaponPrices[i][1]=5000;
    WeaponPrices[i][2]=10000;
    WeaponPrices[i][3]=10000;
    WeaponPrices[i][4]=13000;
    WeaponPrices[i][5]=8000;
    WeaponPrices[i][6]=12000;
    WeaponPrices[i][7]=15000;
    WeaponPrices[i][8]=15000;
    WeaponPrices[i][9]=14000;
    WeaponPrices[i][10]=14000;
    WeaponPrices[i][11]=15000;
    WeaponPrices[i][12]=1000;
}
When i do your code my textdraw is flashing and my mates textdraw to.
Reply
#6

Quote:
Originally Posted by admigo
Посмотреть сообщение
When i do your code my textdraw is flashing and my mates textdraw to.
That code won't interfere with text draws, unless you've muddled it in with some text draw stuff. Try putting my code at the very bottom of your OnGameModeInit callback. Just before the closing brace.
Reply
#7

The weapon dealer can change his prices of his weapons but if i delete the code the weapons are free to buy :$0.
So thats why i want to fix the code.
Pls need fix.
Reply
#8

Quote:
Originally Posted by admigo
Посмотреть сообщение
The weapon dealer can change his prices of his weapons but if i delete the code the weapons are free to buy :$0.
So thats why i want to fix the code.
Pls need fix.
Then, don't delete the code? What seems to be the overall issue... I don't see one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)