SA-MP Forums Archive
crash pawn - 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: crash pawn (/showthread.php?tid=355181)



crash pawn - marquezsanchez - 29.06.2012

hi I've add new function in my script but when a try to compile , I receive pawn librarie has stoped to working :

the function

Quote:
PHP код:
public GetDoorLock(houseId)
{
    if(
gHouseVar[houseId][hLocked] == 0) return "Ouverte";
    else return 
"Fermйe";




Re: crash pawn - iggy1 - 29.06.2012

You can't return constant strings like that, but you can return arrays.

pawn Код:
public GetDoorLock(houseId)
{
    if(gHouseVar[houseId][hLocked] == 0)
    {
        new szStr[] = "Ouverte";
        return szStr;
    }
    new szStr[] = "Fermйe";
    return szStr;
}



Re: crash pawn - marquezsanchez - 29.06.2012

its send me an other error : public functions may not return arrays. so i must use stock??


Re: crash pawn - iggy1 - 29.06.2012

Yeah sorry i completely forgot about that, make it a stock.

If you use it, it doesn't have to be a stock function.
pawn Код:
GetDoorLock(houseId)
{
    if(gHouseVar[houseId][hLocked] == 0)
    {
        new szStr[] = "Ouverte";
        return szStr;
    }
    new szStr[] = "Fermйe";
    return szStr;
}
If you make a function stock, you are just telling the compiler that, if it is not used; leave it out of compilation.


Re: crash pawn - marquezsanchez - 29.06.2012

ok thx;
but plz can you explain me why we can't return string in public function??


Re: crash pawn - marquezsanchez - 29.06.2012

ahh ok thanks.