Problem | Pawn Script Compiler has stopped working
#2

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
Reply


Messages In This Thread
Problem | Pawn Script Compiler has stopped working - by DaRealz - 23.06.2011, 21:12
Re: Problem | Pawn Script Compiler has stopped working - by Basicz - 23.06.2011, 23:27

Forum Jump:


Users browsing this thread: 1 Guest(s)