Help - 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: Help (
/showthread.php?tid=615863)
Help -
MrCallum - 28.08.2016
I am trying to make a stock, if the admin level is 99999 they get 1 more vehicle added on to the Max_playervehicles which is 7, I get these errors:
Код:
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124706) : error 029: invalid expression, assumed zero
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124706) : warning 215: expression has no effect
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124706) : error 001: expected token: ";", but found "if"
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124708) : warning 215: expression has no effect
Код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0) return i;
}
else if(PlayerInfo[playerid][pAdmin] == 99999) // LINE 124706
{
MAX_PLAYERVEHICLES+1; // LINE 124708
}
return -1;
}
Re: Help -
Micko123 - 28.08.2016
instead of else if put just if
Re: Help -
MrCallum - 28.08.2016
But I get
Код:
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124708) : warning 215: expression has no effect
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124712) : warning 209: function "GetPlayerFreeVehicleId" should return a value
For:
Код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0) return i;
}
if(PlayerInfo[playerid][pAdmin] == 99999)
{
MAX_PLAYERVEHICLES+1; // LINE 124708
}
else
return -1;
} // LINE 124712
Re: Help -
Micko123 - 28.08.2016
I don't know but this might help you
PHP код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0)
{
return i;
}
if(PlayerInfo[playerid][pAdmin] == 99999)
{
MAX_PLAYERVEHICLES+1; // LINE 124708
}
}
return 1;
}
Re: Help -
SoLetsGO - 28.08.2016
PHP код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0) return i;
}
if(PlayerInfo[playerid][pAdmin] == 99999)
{
MAX_PLAYERVEHICLES+1; // LINE 124708
}
else
return -1;
} // LINE 124712
"MAX_PLAYERVEHICLES+1;" doesnt make any sense, because you dont initialise any value, you just add two numbers but you don't put that value to a variable. I guess what you want is to return that value:
PHP код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0) return i;
}
if(PlayerInfo[playerid][pAdmin] == 99999)
{
return MAX_PLAYERVEHICLES+1; // LINE 124708
}
else return -1;
} // LINE 124712
Re: Help -
MrCallum - 28.08.2016
I get
Код:
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124710) : warning 215: expression has no effect
For
Код:
MAX_PLAYERVEHICLES+1;
Re: Help -
GoldenLion - 28.08.2016
You need to put ++ there not +1.
Re: Help -
SoLetsGO - 28.08.2016
Try this code with the "return MAX_PLAYERVEHICLES+1;"
:
PHP код:
stock GetPlayerFreeVehicleId(playerid)
{
for(new i; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvModelId] == 0) return i;
}
if(PlayerInfo[playerid][pAdmin] == 99999)
{
return MAX_PLAYERVEHICLES+1; // LINE 124708
}
else return -1;
} // LINE 124712
Re: Help -
MrCallum - 28.08.2016
Quote:
Originally Posted by GoldenLion
You need to put ++ there not +1.
|
I get:
Код:
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124710) : error 022: must be lvalue (non-constant)
C:\Users\Callum(Gaming)\Desktop\Server\gamemodes\Debt.pwn(124710) : warning 215: expression has no effect
Re: Help -
Stinged - 28.08.2016
MAX_PLAYERVEHICLES is clearly a defined word and not a variable.
You can't change its value (other than re-definition)