CMD:w(playerid, params[])
{
new weapid, recieverid, ammo;
recieverid = playerid;
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GRAY, "You are not authorized to use that command!");
if (sscanf(params, "diU", weapid, ammo, recieverid)) return SendClientMessage(playerid, COLOR_GRAY, "Usage: /w [weapon id] [ammo] [player id]");
if (weapid < 0 || weapid > 46) return SendClientMessage(playerid, COLOR_GRAY, "Invalid weapon ID!");
else
{
GivePlayerWeapon(recieverid, weapid, ammo);
}
return 1;
}
|
PHP код:
|
|
1- Don't just send code, explain it.
2- That code will never work. |
|
1- Don't just send code, explain it.
2- That code will never work. |
|
Originally Posted by InSain
I'm trying to make it so that the player id is optional
|
|
if (sscanf(params, "di", weapid, ammo)) return SendClientMessage(playerid, COLOR_GRAY, "Usage: /w [weapon id] [ammo]"); |
|
1- Don't just send code, explain it.
2- That code will never work. |
|
The thread:
What he posted: How's that going to give weapons to other players? |
CMD:w( playerid, params[] ) {
new weapid, ammo,
userid;
if( !IsPlayerAdmin( playerid ) )
return SendClientMessage(playerid, COLOR_GRAY, "You are not authorized to use that command!");
if( sscanf( params, "iiU(65535)", weapid, ammo, userid ) )
return SendClientMessage( playerid, COLOR_GRAY, "Usage: /w [weapon id] [ammo] [optional playerid]" );
if( weapid < 0 || weapid > 46 )
return SendClientMessage(playerid, COLOR_GRAY, "Invalid weapon ID!");
if( ammo <= 0 )
return SendClientMessage(playerid, COLOR_GRAY, "Invalid ammo!");
if( userid == INVALID_PLAYER_ID ) {
userid = playerid;
} else {
if( !IsPlayerConnected( userid ) )
return SendClientMessage( playerid, COLOR_GRAY, "Player isn't connected." );
}
GivePlayerWeapon( userid, weapid, ammo );
SendClientMessage( playerid, COLOR_GRAY, "Gun spawned!" );
return 1;
}
CMD:w(playerid, params[])
{
new weapid, recieverid, ammo;
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GRAY, "You are not authorized to use that command!");
if(sscanf(params, "diu", weapid, ammo, recieverid))
{
if (weapid < 0 || weapid > 46) return SendClientMessage(playerid, COLOR_GRAY, "Invalid weapon ID!");
GivePlayerWeapon(playerid, weapid, ammo);
}
else if(!sscanf(params, "diu", weapid, ammo, recieverid))
{
if(IsPlayerConnected(recieverid))
{
if(weapid < 0 || weapid > 46) return SendClientMessage(playerid, COLOR_GRAY, "Invalid weapon ID!");
GivePlayerWeapon(recieverid, weapid, ammo);
}
}
else return SendClientMessage(playerid, COLOR_WHITE,"Usage: /w [WeapID] [Ammo] [PlayerID(Optional)]");
return 1;
}