01.04.2013, 07:20
Hello guys i have opened a server and i wanna know how to create a simple /rob [id] and if there close to the player the can attempt to could someone help me on this il rep you?
CMD:rob(playerid)
{
new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z);
foreach(new i:Player)
{
if(!IsPlayerInRangeOfPoint(i, 5, x, y, z)) continue;
else
{
GivePlayerMoney(playerid, ( GetPlayerMoney(i) / 100 ) * 20 );
// new st[128]; format(st, 128, "You have robbed %s of $ %d" .. )
SendClientMessage(playerid, -1, st);
}
}
}
This is psuedo CODE, I expect you to complete it.
pawn Код:
|
CMD:rob( playerid, params [] )
{
new
id,
str[128],
str1[128],
pName[MAX_PLAYER_NAME],
pName1[MAX_PLAYER_NAME],
Money;
if( sscanf ( params, "u", id))
return SendClientMessage(playerid, -1, "[USAGE] /rob [ID]");
new
Float:x,
Float:y,
Float:z;
GetPlayerPos(id, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
return SendClientMessage(playerid, -1, "ERROR:You must be near the player!");
if( id == playerid )
return SendClientMessage(playerid, -1, "ERROR:You cannot rob yourself!");
if( id == INVALID_PLAYER_ID )
return SendClientMessage(playerid, -1, "ERROR: Player is not connected");
if( IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, -1, "ERROR:You cannot use this command whilst being inside a vehicle!");
if( IsPlayerInAnyVehicle(id))
return SendClientMessage(playerid, RED, "ERROR: You cannot rob someone who is inside a vehicle!");
new
luck = random(2);
if ( luck == 0 )
{
format( str, 128, "[FAIL] %s[%d] has caught you trying to dig into his pockets!", GetName(id), id);
SendClientMessage(playerid, -1, str );
format( str, 128, "[ROB] %s[%d] has tried to rob you, but failed!", GetName(playerid), playerid);
SendClientMessage(id, -1, str );
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1 );
}
else
{
GetPlayerName(id, pName, sizeof(pName));
GetPlayerName(playerid, pName1, sizeof(pName1));
Money = GetPlayerMoney(id);
new
RobbedMoney = random( Money );
GivePlayerMoney(playerid, RobbedMoney);
GivePlayerMoney(id, -RobbedMoney);
format(str, sizeof(str), "[ROBBED] You have succesfully robbed $%d from %s[%d]", RobbedMoney, pName, id);
SendClientMessage(playerid, -1, str);
format(str1, sizeof(str1), "[ROBBED] %s[%d] has robbed $%d of you!", pName1, playerid, RobbedMoney);
SendClientMessage(id, -1, str1);
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
}
return 1;
}
This is psuedo CODE, I expect you to complete it.
pawn Код:
|