Problem with checking a variable. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with checking a variable. (
/showthread.php?tid=205992)
Problem with checking a variable. -
sobolanux - 02.01.2011
Hello there. I have a little problem with checking a variable. I`ll show you the code and explain it.
Код:
if(GetPVarInt(playerid, "skinselectionscreen") == 1)
{
new selector;
if((newkeys & KEY_SPRINT) && !(oldkeys & KEY_SPRINT))
{
if(GetPlayerSkin(playerid) == 299)
{
selector = 0;
}
else selector = GetPlayerSkin(playerid) + 1;
SetPlayerSkin(playerid, selector);
}
else if((newkeys & KEY_WALK) && !(oldkeys & KEY_WALK))
{
if(GetPlayerSkin(playerid) == 0)
{
selector = 299;
}
else selector = GetPlayerSkin(playerid) - 1;
SetPlayerSkin(playerid, selector);
}
else if((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
{
new counter = 0;
for(new i=0; i++; i<=30)
{
if(forbiddenSkins[i] == selector) counter == 1;
}
if(counter == 0)
{
SetPlayerPos(playerid, -1409.2100,-305.9026,14.1484);
SetCameraBehindPlayer(playerid);
SetPVarInt(playerid, "skinselectionscreen", 0);
TogglePlayerControllable(playerid, 1);
counter = 0;
}
else GameTextForPlayer(playerid, "~r~You are not allowed to use this skin!", 3000, 3);
}
I use the variable 'selector' to check when a player changes the skins. (skin selection). Then, when you hit "JUMP", I want to check the value of 'selector' and set the skin according to it. This works fine.
Now, I need to make some restrctions. So, I used an array with the forbidden skins. I use a counter, and check if the selector is the same to any number in the array (using the little for structure). Then, if it is, the counter is set to 1 and you can`t spawn. If it`s 0 you can spawn. The problem is that any skin I choose (from the forbidden ones), it doesn`t work. Maybe you should come in with some suggestions?
Re: Problem with checking a variable. -
sobolanux - 03.01.2011
Okay, problem solved. Lock!