05.12.2015, 08:34
bracket ~.~
PHP код:
COMMAND:rob(playerid, params[]){
if(PlayerInfo[playerid][pSpawned] == 1){
new idx,giveplayerid,string[256],tmp[256],amount;
tmp = strtok(params, idx);
if(!strlen(tmp)){
new Players;
for(new i = 0; i < GetMaxPlayers(); i++){
if(IsPlayerConnected(i) && i != playerid && PlayerInfo[i][pSpawned] == 1 && GetDistanceBetweenPlayers(playerid,i) < 10){
Players ++;
if(Players > 0) giveplayerid = i; break;
}
}
if(Players == 0) return SendClientMessage(playerid, COLOR_ERROR, "No Players Close Enough To Rob.");
} else {
giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid)){
format(string, sizeof(string), "That Player Is Not Connected.");
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
if(giveplayerid == playerid){
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Rob Yourself.");
return 1;
}
if(PlayerInfo[playerid][pJailed] == 1){
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command In Jail.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3){
format(string, sizeof(string), "%s(%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(giveplayerid)){
format(string, sizeof(string), "%s(%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) != PLAYER_STATE_ONFOOT){
format(string, sizeof(string), "%s(%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT){
format(string, sizeof(string), "%s(%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(PlayerInfo[playerid][pRobTime] > 0){
SendClientMessage(playerid, COLOR_ERROR, "Please Wait Before Attempting To Rob Someone Again.");
return 1;
}
if(PlayerInfo[playerid][pJailed] == 1){
SendClientMessage(playerid, COLOR_ERROR, "You Can't use this command In Jail.");
return 1;
}
switch(random(10)){
case 1..5 : {
PlayerInfo[playerid][pRobTime] = 30;
amount = GetPlayerMoney(giveplayerid)/4;
if(GetPlayerMoney(giveplayerid) >= 1500000){
amount = 500000;
amount = GetPlayerMoney(giveplayerid)/32;
format(string, sizeof(string), "You Have Robbed $%d From %s(%d).",amount,PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_SKYBLUE, string);
format(string, sizeof(string), "ROBBED %s~N~~G~$%d",PlayerInfo[giveplayerid][pName],amount);
GameTextForPlayer(playerid,string, 4000, 3);
format(string, sizeof(string), "%s(%d) Has Robbed $%d From You.",PlayerInfo[playerid][pName],playerid,amount);
SendClientMessage(giveplayerid, COLOR_SKYBLUE, string);
format(string, sizeof(string), "ROBBED BY %s~n~~G~$%d",PlayerInfo[playerid][pName],amount);
GameTextForPlayer(giveplayerid,string, 4000, 3);
LastRobbed[playerid] = giveplayerid;
GivePlayerMoney(giveplayerid, - amount);
GivePlayerMoney(playerid, amount);
SetPlayerScore(playerid,GetPlayerScore(playerid) + 1);
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) - 1);
}
}
case 6..9 : {
PlayerInfo[playerid][pRobTime] = 20;
format(string, sizeof(string), "You Have Failed To Rob %s(%d).",PlayerInfo[playerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_SKYBLUE, string);
format(string, sizeof(string), "Robbery Attempt Failed"PlayerInfo[playerid][pName],amount);
GameTextForPlayer(playerid,string, 4000, 3);
format(string, sizeof(string), "%s(%d) Has Failed To Rob You.",PlayerInfo[playerid][pName],playerid);
SendClientMessage(giveplayerid, COLOR_SKYBLUE, string);
}
}
} else {
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
}
return 1;
}