Command help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command help (
/showthread.php?tid=635399)
Command help -
MrFantasy - 06.06.2017
Code:
CMD:rob(playerid, params[])
{
new tid, str[256], Float:x, Float:y, Float:z, RCash;
GetPlayerPos(tid, x, y, z);
if(gTeam[playerid] != CIVI) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}A law enforcer can not rob");
if(RobTime[playerid] == 1) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}Please wait before robbing someone again.");
if(sscanf(params, "u", tid)) return SCM(playerid, BLREN, ""COL_RED"[USAGE]:{FFFFFF}/rob (playerid/partofname)");
if(tid == playerid) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}You cannot rob yourself!");
if(IsPlayerPaused(playerid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s is paused!", GetPlayerNameEx(tid));
if(!IsPlayerConnected(tid)) return ErrorMessage(playerid, 1);
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(tid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s has to be in the same vehicle as you to be able to rob!", GetPlayerNameEx(tid));
}
return 1;
}
Code:
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(tid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s has to be in the same vehicle as you to be able to rob!", GetPlayerNameEx(tid));
}
warning 202: number of arguments does not match definition
and
Code:
if(IsPlayerPaused(playerid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s is paused!", GetPlayerNameEx(tid));
warning 202: number of arguments does not match definition
Code:
public IsPlayerPaused(playerid) return Paused[playerid];
public PauseCheck()
{
new ps;
for(new id=0; id < MAX_PLAYERS; id++)
{
if(!IsPlayerConnected(id)) continue;
ps = GetPlayerState(id);
if(ps != PLAYER_STATE_ONFOOT && ps != PLAYER_STATE_DRIVER && ps != PLAYER_STATE_PASSENGER) continue;
for(new x = FPS_CHECKS-1; x > 0; x--)
{
PlayerFPS[id][x] = PlayerFPS[id][x - 1];
}
PlayerFPS[id][0] = GetPlayerDrunkLevel(id);
for(new x = 0; x < FPS_CHECKS; x++)
{
if(x == FPS_CHECKS - 1)
{
if(Paused[id] != 1) PlayerHasPaused(id);
Paused[id] = 1;
break;
}
if(PlayerFPS[id][x] == PlayerFPS[id][x + 1]) continue;
if(Paused[id] != 0) PlayerHasUnpaused(id);
Paused[id] = 0;
break;
}
if(PlayerFPS[id][0] < 100)
{
SetPlayerDrunkLevel(id, 2000);
}
}
return 1;
}
What is wrong?
Re: Command help -
JasonRiggs - 06.06.2017
SendClientMessage doesn't work with Floats..
Code:
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(tid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s has to be in the same vehicle as you to be able to rob!", GetPlayerNameEx(tid));
}
change it to be like that
Code:
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(tid))
{
format(string, sizeof(string), "[ERROR]: {FFFFFF}%s has to be in the same vehicle as you to be able to rob!", GetPlayerNameEx(tid));
SendClientMessage(playerid, RED, string);
return 1;
}
and change this
Code:
if(IsPlayerPaused(playerid)) return SCM(playerid, RED, ""COL_BLUE"[ERROR]: {FFFFFF}%s is paused!", GetPlayerNameEx(tid));
to this
Code:
if(IsPlayerPaused(playerid))
{
format(string, sizeof(string), "[ERROR]: {FFFFFF}%s is paused!", GetPlayerNameEx(tid));
SendClientMessage(playerid, RED, string);
return 1;
}
and make sure to add at the top of the function or cmd