[Help] if(.....) problems
#1

hey all, i'm new at scripting and today i've done /cuff and /uncuff but my problem is not the command, it works mainly, but i can't figure why the script ignores some if(....) lines

look:
enum playerinfo_enum
{
Claimed,
MoneyClaimed,
LoggedIn,
Cuffed
};
forward SetPlayerTeamFromClass(playerid,teamid);
forward SetPlayerToTeamColor(playerid);
public SetPlayerTeamFromClass(playerid,teamid)
{
if (teamid == 1)
{
gTeam[playerid] = Civils;
SetPlayerTeam(playerid,1);
}
else if (teamid == 2)
{
gTeam[playerid] = Cops;
SetPlayerTeam(playerid,2);
}
}

then

dcmd_uncuff(playerid,params[])
{
new Float:X, Float:Y, Float:Z, target,teamid;
teamid = GetPlayerTeam(playerid);
if(sscanf(params,"d",target)) return SendClientMessage(playerid,red,"USAGE: /uncuff [ID]");
GetPlayerPos(playerid,X,Y,Z);
if(teamid == Cops)
{
if(!IsPlayerInRangeOfPoint(target,3,X,Y,Z)) return SendClientMessage(playerid,red,"Player is too far to uncuff");
TogglePlayerControllable(target,true);
SendClientMessage(target,lightblue,"Handcuffs have been removed.");
PlayerInfo[target][Cuffed] = 0;
return 1;
}
else if (teamid != Cops) return SendClientMessage(playerid,red,"You are not a Law Enforcement Officer");
else if (PlayerInfo[target][Cuffed] == 0) return SendClientMessage(playerid,red,"Player is not cuffed");
return 1;
}
dcmd_cuff(playerid,params[])
{
new Float:X, Float:Y, Float:Z, target, teamid,targetteam;
teamid = GetPlayerTeam(playerid);
targetteam = GetPlayerTeam(target);
GetPlayerPos(playerid,X,Y,Z);
if (sscanf(params,"d",target)) return SendClientMessage(playerid,red,"USAGE: /cuff [ID]");
if (teamid == Cops)
{
if (!IsPlayerInRangeOfPoint(target,3,X,Y,Z)) return SendClientMessage(playerid,red,"Player Is Too Far");
TogglePlayerControllable(target,false);
GameTextForPlayer(target," You Are Cuffed.",3000,6);
PlayerInfo[target][Cuffed] = 1;
SendClientMessage(target,lightblue,"You Got Handcuffed.");
return 1;
}
else if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't cuff someone from a vehicle,get out first");
else if (IsPlayerInAnyVehicle(target)) return SendClientMessage(playerid,red,"You can't cuff someone in car, take him out first");
else if (targetteam == Cops) return SendClientMessage(playerid,red,"You cannot cuff orther Law Enforcement Officers");
else if (PlayerInfo[target][Cuffed]==1) return SendClientMessage(playerid,red,"Player is already cuffed");
else if (teamid != Cops) return SendClientMessage(playerid,red,"You are not a Law Enforcement Officer");
return 1;
}

the problems are:
on cuff:
else if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't cuff someone from a vehicle,get out first");
else if (IsPlayerInAnyVehicle(target)) return SendClientMessage(playerid,red,"You can't cuff someone in car, take him out first");
else if (targetteam == Cops) return SendClientMessage(playerid,red,"You cannot cuff orther Law Enforcement Officers");
else if (PlayerInfo[target][Cuffed]==1) return SendClientMessage(playerid,red,"Player is already cuffed");

on uncuff:

else if (PlayerInfo[target][Cuffed] == 0) return SendClientMessage(playerid,red,"Player is not cuffed");

PS: i downloaded a cnr script from the forum and i saw that lines with if(...) end with true or false, i can't do that, can you tell me how to put it?
like... if(PlayerInfo[target][Cuffed] == true), i would like that but it says "tag mismatch"

please also tell me how to put kind of spoilers to load the script with colors
Reply
#2

pawn Код:
if(PlayerInfo[target][Cuffed])
Reply
#3

already tried not working... i can cuff and uncuff myself how many times i want
Reply
#4

pawn Код:
dcmd_uncuff(playerid,params[])
{
    new Float:X, Float:Y, Float:Z, target,teamid;
    teamid = GetPlayerTeam(playerid);
    if(sscanf(params,"d",target)) return SendClientMessage(playerid,red,"USAGE: /uncuff [ID]");
    GetPlayerPos(playerid,X,Y,Z);
    if (teamid != Cops) return SendClientMessage(playerid,red,"You are not a Law Enforcement Officer");
    if (PlayerInfo[target][Cuffed] == 0) return SendClientMessage(playerid,red,"Player is not cuffed");
    if(!IsPlayerInRangeOfPoint(target,3,X,Y,Z)) return SendClientMessage(playerid,red,"Player is too far to uncuff");
    TogglePlayerControllable(target,true);
    SendClientMessage(target,lightblue,"Handcuffs have been removed.");
    PlayerInfo[target][Cuffed] = 0;
    return 1;
}
pawn Код:
dcmd_cuff(playerid,params[])
{
    new Float:X, Float:Y, Float:Z, target, teamid,targetteam;
    teamid = GetPlayerTeam(playerid);
    targetteam = GetPlayerTeam(target);
    GetPlayerPos(playerid,X,Y,Z);
    if (sscanf(params,"d",target)) return SendClientMessage(playerid,red,"USAGE: /cuff [ID]");
    if (teamid != Cops) return SendClientMessage(playerid,red,"You are not a Law Enforcement Officer");
    if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't cuff someone from a vehicle,get out first");
    if (IsPlayerInAnyVehicle(target)) return SendClientMessage(playerid,red,"You can't cuff someone in car, take him out first");
    if (targetteam == Cops) return SendClientMessage(playerid,red,"You cannot cuff orther Law Enforcement Officers");
    if (PlayerInfo[target][Cuffed]==1) return SendClientMessage(playerid,red,"Player is already cuffed");
    if (!IsPlayerInRangeOfPoint(target,3,X,Y,Z)) return SendClientMessage(playerid,red,"Player Is Too Far");
    TogglePlayerControllable(target,false);
    GameTextForPlayer(target," You Are Cuffed.",3000,6);
    PlayerInfo[target][Cuffed] = 1;
    SendClientMessage(target,lightblue,"You Got Handcuffed.");
    return 1;
}
Reply
#5

works thank you very much

last thing, how to add a pawn code in my posts?
Reply
#6

[ pawn ] Your Code Here [ /pawn ]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)