SA-MP Forums Archive
[SOLVED] Pawno giving false errors - 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: [SOLVED] Pawno giving false errors (/showthread.php?tid=358473)



[SOLVED] Pawno giving false errors - [FSaF]Jarno - 10.07.2012

My pawno is giving me false errors about certain variables "already being defined", although they are not. They are enclosed in their own brackets, like that:
Код:
if (blah)
{
    new shit;
    shit = 1;
}
if (blah2)
{
    new shit;
    shit = 2;
}
EDIT: Btw, if i don't make a new variable (just create it once), when the variable is used the server crashes -.-


Re: Pawno giving false errors - next-studio|TheKiller - 10.07.2012

Код:
if (blah)
{
    new shit;
    shit = 1;
}
else if (blah2)
{
    new shit;
    shit = 2;
}



Re: Pawno giving false errors - Scrillex - 10.07.2012

if (blah)
{
new shit;
shit = 1;
}
else if (blah2)
{
new shit;
shit = 2;
}

or try to end it with return 1; like

if (blah)
{
new shit;
shit = 1;
return 1;
}
if (blah2)
{
new shit;
shit = 2;
return 1;
}


Re: Pawno giving false errors - [FSaF]Jarno - 10.07.2012

That is not how pawno works, there shouldn't be a problem with variables intersecting if they are in their own brackets.


Re: Pawno giving false errors - next-studio|TheKiller - 10.07.2012

if , or else if, cannot be returned or breaked.

@[FSaF]Jarno
use if and else if.

If it still does not work, create the variable outside of the if / else if, and configure it inside of the if / else if.


Re: Pawno giving false errors - Scrillex - 10.07.2012

Quote:
Originally Posted by next-studio|TheKiller
Посмотреть сообщение
if , or else if, cannot be returned or breaked.

@[FSaF]Jarno
use if and else if.
it can because look code like yours ...

Quote:

if(classid == 0 || classid == 1 || classid == 2)
{
gTeam[playerid] = GS;
GameTextForPlayer(playerid,"~b~Cripz",3000,5); // This will show up an Text , when you select your class
SetPlayerPos(playerid,1975.2399,-1220.0157,25.0779); // position of the player in the class selection
SetPlayerCameraPos(playerid,1969.5686,-1224.0016,24.9909); // Cameraposition
SetPlayerCameraLookAt(playerid,1975.2399,-1220.0157,25.0779);
SetPlayerFacingAngle(playerid,122.4500);
SetPlayerColor(playerid, COLOR_GS);
return 1;
}
else if(classid == 3 || classid == 4 || classid == 5)
{
gTeam[playerid] = Ballas;
GameTextForPlayer(playerid,"~r~Bloodz",3000,5); // This will show up an Text , when you select your class
SetPlayerPos(playerid,1975.2399,-1220.0157,25.0779); // position of the player in the class selection
SetPlayerCameraPos(playerid,1969.5686,-1224.0016,24.9909); // Cameraposition
SetPlayerCameraLookAt(playerid,1975.2399,-1220.0157,25.0779);
SetPlayerFacingAngle(playerid,122.4500);
SetPlayerColor(playerid,COLOR_Ballas);
return 1;
}




Re: Pawno giving false errors - [FSaF]Jarno - 10.07.2012

they can be returned, that way it will skip the rest of the script like this:

shit = 1;
if (shit == 1) return 1; // This returns 1 so the script below won't be used
ass = 3;
shit = 2;


Re: Pawno giving false errors - next-studio|TheKiller - 10.07.2012

They can be returned, but they will get returned automatically if the string / code / whatever is found / not found / whatever.
And why are you going to use more resources, for the codes which can be removed?

This is just what i think.


Re: Pawno giving false errors - [FSaF]Jarno - 10.07.2012

This is not a problem like that, it's some kind of a glitch in pawno. I am a professional scripter and i know it's not a problem with that. (AND, i already tried it)


Re: Pawno giving false errors - [FSaF]Jarno - 10.07.2012

Problem solved, (wasn't a problem with the script, the reason for this behavior still is a mystery, i renamed some variables and it started working.)