Need Help With Player Variables -
Toxas - 06.12.2014
I'm Trying to make a Script that sees where you are in a Background Story (that has multiple parts)
throught Pvars (I don't know if it's the best way, if there is a better way please tell me)
Код:
Line 91: SetPVarInt(playerid, "BSP", 0);
This is To Show that I did set it
Код:
Line 119: if (GetPVarInt(playerid, "BSP")) = 0;
Line 120 {
Line 121 - 134: //Part One Text
Line 135: SetPVarInt(playerid, "BSP", 1);
Line 136: }
Line 137: if (GetPVarInt(playerid, "BSP")) = 1;
Line 121: {
Line 121-(not done yet): //Part Two Text
Line ???: {
Line ???: SetPVarInt(playerid, "BSP", 2);
etc......
And I get These Errors
Код:
D:\Program Files (x86)\Rockstar Games\GTA San Andreas\Server\gamemodes\XXXXX.pwn(119) : error 029: invalid expression, assumed zero
D:\Program Files (x86)\Rockstar Games\GTA San Andreas\Server\gamemodes\XXXXX.pwn(119) : warning 215: expression has no effect
D:\Program Files (x86)\Rockstar Games\GTA San Andreas\Server\gamemodes\XXXXX.pwn(137) : error 029: invalid expression, assumed zero
D:\Program Files (x86)\Rockstar Games\GTA San Andreas\Server\gamemodes\XXXXX.pwn(137) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: Need Help With Player Variables -
PowerPC603 - 06.12.2014
pawn Код:
Line 119: if (GetPVarInt(playerid, "BSP") == 0)
Line 120 {
Line 121 - 134: //Part One Text
Line 135: SetPVarInt(playerid, "BSP", 1);
Line 136: }
Line 137: if (GetPVarInt(playerid, "BSP") == 1);
Line 121: {
Line 121-(not done yet): //Part Two Text
Line ???: {
Line ???: SetPVarInt(playerid, "BSP", 2);
== equals to checking if a value is the same.
= equals to setting an value inside a variable.
Also, after an if-condition, you don't need to put ";", as you'll be closing the code after the if-statement while no code has been executed.
Even better would be:
pawn Код:
switch (GetPVarInt(playerid, "BSP"))
{
case 0:
{
//Part One Text
SetPVarInt(playerid, "BSP", 1);
}
case 1:
{
//Part Two Text
SetPVarInt(playerid, "BSP", 2);
}
}
Otherwise your code will just run through all conditions in one go, because you're setting the variable to the next value, and the next if-statement checks that value again, execuitng that code as well.
Using switch-case statements, you only execute one condition.
Re: Need Help With Player Variables -
Capua - 06.12.2014
Use normal variables instead.. example:
Somewhere on top of the script put
Setting value for BSP player variable:
When we wanna see what the value is for a player:
pawn Код:
if(BSP[playerid] == 0)
{
//nope
}
if(BSP[playerid] == 1)
{
//ys
}
etc..
Re: Need Help With Player Variables -
Toxas - 06.12.2014
Quote:
Originally Posted by PowerPC603
pawn Код:
Line 119: if (GetPVarInt(playerid, "BSP") == 0) Line 120 { Line 121 - 134: //Part One Text Line 135: SetPVarInt(playerid, "BSP", 1); Line 136: } Line 137: if (GetPVarInt(playerid, "BSP") == 1); Line 121: { Line 121-(not done yet): //Part Two Text Line ???: { Line ???: SetPVarInt(playerid, "BSP", 2);
== equals to checking if a value is the same.
= equals to setting an value inside a variable.
Also, after an if-condition, you don't need to put ";", as you'll be closing the code after the if-statement while no code has been executed.
Even better would be:
pawn Код:
switch (GetPVarInt(playerid, "BSP")) { case 0: { //Part One Text SetPVarInt(playerid, "BSP", 1); } case 1: { //Part Two Text SetPVarInt(playerid, "BSP", 2); } }
Otherwise your code will just run through all conditions in one go, because you're setting the variable to the next value, and the next if-statement checks that value again, execuitng that code as well.
Using switch-case statements, you only execute one condition.
|
Thanks, really, I've been stuck on this for weeks.
Quote:
Originally Posted by Capua
Use normal variables instead.. example:
Somewhere on top of the script put
Setting value for BSP player variable:
When we wanna see what the value is for a player:
pawn Код:
if(BSP[playerid] == 0) { //nope } if(BSP[playerid] == 1) { //ys }
etc..
|
I tried with Normal Variables, and it got too confusing at one point
Re: Need Help With Player Variables -
Toxas - 06.12.2014
Even better would be:
pawn Код:
switch (GetPVarInt(playerid, "BSP"))
{
case 0:
{
//Part One Text
SetPVarInt(playerid, "BSP", 1);
}
case 1:
{
//Part Two Text
SetPVarInt(playerid, "BSP", 2);
}
}
Otherwise your code will just run through all conditions in one go, because you're setting the variable to the next value, and the next if-statement checks that value again, execuitng that code as well.
Using switch-case statements, you only execute one condition.[/QUOTE]
Since I have multiple Lines Between case 0: and case 1: it's giving me this error
Код:
D:\Program Files (x86)\Rockstar Games\GTA San Andreas\Server\gamemodes\XXXXX.pwn(145) : error 002: only a single statement (or expression) can follow each "case"
And I have it exactly like you do