A question
#1

Well, i have a give stuff command, and when i try to give someone some cocaine (example: /give 3 cocaine 123) it returns me 0.. i never used sscanf this way.
pawn Код:
CMD:give( playerid, params[] )
{
    new szOption[128], szString[128], iVictim;

    if( sscanf( params, "us[128]", iVictim, szOption ) )
    {
        ShowSyntaxMessage( playerid, "/give [playerid][option]" );
        SendClientMessage( playerid, COLOR_BEIGE, "{6699cc}OPTIONS:{ffffff} gun armor cash cocaine heroin ecstasy crack ");
        SendClientMessage( playerid, COLOR_BEIGE, "{6699cc}OPTIONS:{ffffff} weed meth steroids phone watch materials ciggy ");
        SendClientMessage( playerid, COLOR_BEIGE, "{6699cc}OPTIONS:{ffffff} walkie fish seeds chemicals snacks ");
        return 1;
    }
   
    new Float:x, Float:y, Float:z;
    GetPlayerPos( iVictim, x, y, z );
    if( !IsPlayerInRangeOfPoint( playerid, 3.0, x, y, z ) ) return ShowBarMessage( playerid, "You're not near that player." );
   
    if( strcmp( szOption, "gun", true ) == 0 )
    {
        new szWepName[64];
        if( GetPlayerWeapon( playerid ) < 1 ) return ShowBarMessage( playerid, "You dont have any gun." );

        GetWeaponName( GetPlayerWeapon( playerid ), szWepName, 64 );
       
        GivePlayerWeapon( iVictim, GetPlayerWeapon( playerid ), GetPlayerAmmo( playerid ) );
        RemovePlayerWeapon( playerid, GetPlayerWeapon( playerid ) );

        format( szString, 128, "** %s extends his hand giving %s a %s.", GetRPName( playerid ), GetRPName( iVictim ), szWepName );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        format( szString, 128, "INFO: You was given a %s with %d of ammo.", szWepName, GetPlayerAmmo( iVictim ) );
        SendClientMessage( playerid, COLOR_SUCCESS, szString );

        return 1;
    }
   
    if( strcmp( szOption, "armor", true ) == 0 )
    {
        new Float:fAR, Float:fAR2;
        fAR = GetPlayerArmour( playerid, fAR );
        fAR2 = GetPlayerArmour( iVictim, fAR2 );

        if( floatcmp( fAR, 0 ) ) return ShowBarMessage( playerid, "You dont have a armor." );


        SetPlayerArmour( iVictim, fAR2+fAR );
        SetPlayerArmour( playerid, -fAR );

        format( szString, 128, "** %s extends his hand giving %s an armour.", GetRPName( playerid ), GetRPName( iVictim ) );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        return 1;
    }
   
    if( strcmp( szOption, "cash", true ) == 0 )
    {
        new iCash;

        if( sscanf( params, "ui", iVictim, iCash ) ) return ShowSyntaxMessage( playerid, "/give [playerid] cash [amount]");
        if( GetPlayerMoney( playerid ) < iCash ) return ShowBarMessage( playerid, "You dont have enough cash." );


        GivePlayerMoney( iVictim, iCash );
        GivePlayerMoney( playerid, -iCash );

        format( szString, 128, "** %s extends his hand giving %s a stack of money.", GetRPName( playerid ), GetRPName( iVictim ) );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        format( szString, 128, "INFO: You've received %d of %s", iCash, szOption );
        SendClientMessage( playerid, COLOR_SUCCESS, szString );

        return 1;
    }
   
    if( strcmp( szOption, "cocaine", true ) == 0 )
    {
        new iDrug;

        if( sscanf( params, "ui", iVictim, iDrug ) ) return ShowSyntaxMessage( playerid, "/give [playerid] cocaine [amount]");
        if( PlayerInfo[playerid][Cocaine] < iDrug ) return ShowBarMessage( playerid, "You dont have enough cocaine." );

        PlayerInfo[iVictim][Cocaine] += iDrug;
        PlayerInfo[playerid][Cocaine] -= iDrug;

        format( szString, 128, "** %s extends his hand giving %s a stack of drugs.", GetRPName( playerid ), GetRPName( iVictim ) );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        format( szString, 128, "INFO: You've received %d of %s", iDrug, szOption );
        SendClientMessage( playerid, COLOR_SUCCESS, szString );

        return 1;
    }
   
    if( strcmp( szOption, "heroin", true ) == 0 )
    {
        new iDrug;

        if( sscanf( params, "ui", iVictim, iDrug ) ) return ShowSyntaxMessage( playerid, "/give [playerid] heroin [amount]");
        if( PlayerInfo[playerid][Heroin] < iDrug ) return ShowBarMessage( playerid, "You dont have enough heroin." );

        PlayerInfo[iVictim][Heroin] += iDrug;
        PlayerInfo[playerid][Heroin] -= iDrug;

        format( szString, 128, "** %s extends his hand giving %s a stack of drugs.", GetRPName( playerid ), GetRPName( iVictim ) );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        format( szString, 128, "INFO: You've received %d of %s", iDrug, szOption );
        SendClientMessage( playerid, COLOR_SUCCESS, szString );

        return 1;
    }
   
    if( strcmp( szOption, "ecstasy", true ) == 0 )
    {
        new iDrug;

        if( sscanf( params, "ui", iVictim, iDrug ) ) return ShowSyntaxMessage( playerid, "/give [playerid] ecstasy [amount]");
        if( PlayerInfo[playerid][Ecstasy] < iDrug ) return ShowBarMessage( playerid, "You dont have enough ecstasy." );

        PlayerInfo[iVictim][Ecstasy] += iDrug;
        PlayerInfo[playerid][Ecstasy] -= iDrug;

        format( szString, 128, "** %s extends his hand giving %s a stack of drugs.", GetRPName( playerid ), GetRPName( iVictim ) );
        ProxDetector( 20.0, playerid, szString, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION );

        format( szString, 128, "INFO: You've received %d of %s", iDrug, szOption );
        SendClientMessage( playerid, COLOR_SUCCESS, szString );

        return 1;
// ...... it keeps going, it's a large code.
Somebody?

oh yeah and, It is possible to remove vehicle gray dots in the radar? If yes, how?
Reply
#2

Had this problem before, because of 0.3d.

Change:
if( sscanf( params, "us[128]", iVictim, szOption ) )
To:
if( sscanf( params, "ds[128]", iVictim, szOption ) )

Somehow 0.3d settings for sscanf are messed up (changed).
This worked for me, give it a try and let me know

EDIT:

Oh and doing this you're not getting all the parameters needed.
Since you're looking for 3:
- id
- option (%s)
- value (%i)
Reply
#3

Nono, that part works, i mean, when i use cocaine it wont show me anything, the rest works fine.

And some "items" dont use the param 'value'.
Reply
#4

Well change the way you get parameters, as I said change "us" to "ds".
Reply
#5

Nah, still doesnt works.
Reply
#6

Change all the "u" parameters while using sscanf to "d". In the whole code of the give command, then try again.
Reply
#7

Nope, i also just did a debug, doesnt works.
Reply
#8

Wah, I don't have any more ideas.

The id 0 bug is a constant companion of most SAMP servers, sadly.
Reply
#9

It's not the playerid, it's the value you want to send to a player, but thanks for trying.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)