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.
oh yeah and, It is possible to remove vehicle gray dots in the radar? If yes, how?
Had this problem before, because of 0.3d.
Somehow 0.3d settings for sscanf are messed up (changed).
Oh and doing this you're not getting all the parameters needed.
Nono, that part works, i mean, when i use cocaine it wont show me anything, the rest works fine.
Change all the "u" parameters while using sscanf to "d". In the whole code of the give command, then try again.
Wah, I don't have any more ideas.
It's not the playerid, it's the value you want to send to a player, but thanks for trying.