New Variable in gamemodeinit? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: New Variable in gamemodeinit? (
/showthread.php?tid=293074)
New Variable in gamemodeinit? -
Admigo - 26.10.2011
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
Re: New Variable in gamemodeinit? -
[MWR]Blood - 26.10.2011
You can't as it contains a player variable.
Re: New Variable in gamemodeinit? -
Ash. - 26.10.2011
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;
}
Re: New Variable in gamemodeinit? -
Vince - 26.10.2011
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, ...};
Re: New Variable in gamemodeinit? -
Admigo - 26.10.2011
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.
Re: New Variable in gamemodeinit? -
Ash. - 26.10.2011
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.
Re: New Variable in gamemodeinit? -
Admigo - 27.10.2011
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.
Re: New Variable in gamemodeinit? -
Ash. - 27.10.2011
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?