SA-MP Forums Archive
Problem | Pawn Script Compiler has stopped working - 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 | Pawn Script Compiler has stopped working (/showthread.php?tid=263881)



Problem | Pawn Script Compiler has stopped working - DaRealz - 23.06.2011

Ok this is the problem...
The Pawn compiler button has worked every time... the only time it stops working is if i add this command:
pawn Код:
if(strcmp(cmdtext, "/cuff", true, 5) == 0) // '/cuff'
{
    if(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
    {
        new targetid = strval(params);
        TogglePlayerControllable(targetid,0);
        SendClientMessage(targetid, 0xFFFFCCAA, "You have been cuffed by a LEO.")
        SendClientMessage(playerid, 0xFFFFCCAA, "You have cuffed a player.")
    }
    else
    {
        SendClientMessage(playerid, 0xFFFFCCAA, "You are not a leo !")
    }
    return 1;
}
If i don't have that in the script, compiler works alright...
Im new to scripting, so im wondering if this command would atleast work on the player, or if theres something wrong with the script...

(i've been on vacation, so i didn't script much, i forgot most of what i learned before, so i don't really know how to do these commands anymore where u do /cuff [id] or like /warn [id] [reason].)


Re: Problem | Pawn Script Compiler has stopped working - Basicz - 23.06.2011

pawn Код:
targetid = strval(params);
^ Did you have that params variable?
pawn Код:
(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
^ You have that variable, right? or did you have defined it like ...
pawn Код:
#define        faction_swat        ( 50 )
#define        faction_army       ( 49 )
#define        faction_lspd         ( 77 )
#define        faction_ss            ( 76 )
That could be if you placed the script outside of
pawn Код:
OnPlayerCommandText( playerid, cmdtext[ ] )
That could be because your "SendClientMessage" doesnt have a ";".

Anyway, it's more easier to do it with ZCMD + sscanf.
pawn Код:
COMMAND:cuff( playerid, params[ ] )
{
    new
        targetID
    ;

    if(pFaction[playerid] != faction_army || pFaction[playerid] != faction_swat || pFaction[playerid] != faction_lspd || pFaction[playerid] != faction_ss)
        return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}You are not a leo." );

    if ( sscanf( params, "u", targetID ) )
        return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}/cuff < playerID / partOfName>." );

    if ( targetID == INVALID_PLAYER_ID )
        return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}Invalid player." );

    new
       Float: targetPos[ 3 ]
    ;

    GetPlayerPos( targetID, targetPos[ 0 ], targetPos[ 1 ], targetPos[ 2 ] );

    if ( !IsPlayerInRangeOfPoint( playerid, 3.0 /* The range, you can change it */, targetPos[ 0 ], targetPos[ 1 ], targetPos[ 2 ] )
        return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}You need to be near from the people you want to cuff." );

    new
        szString[ 128 ],
        szCuffer[ 24 ],
        szVictim[ 24 ]
    ;

    GetPlayerName( playerid, szCuffer, sizeof szCuffer ); GetPlayerName( targetid, szVictim, sizeof szVictim );

    format( szString, sizeof szString, "* You have been cuffed by a LEO named : %s.", szCuffer );

    SendClientMessage( targetID, 0xAAAAAAAA, szString );

    format( szString, sizeof szString, "* You have cuffed suspect named : %s.", szVictim );

    SendClientMessage( playerid, 0xAAAAAAAAA, szString );

    TogglePlayerControllable( targetID, 0 );

    return 1;
}
Sorry if there are a typo, I'm still sleepy at this morning. :P