Need help cmd:detain -
stundje - 10.03.2014
Hello guys, I am working on a script for my friend but this command won't work it is supposed to be working but it doesnt put someone in the car, any idea's why it doesnt work?
pawn Код:
CMD:detain(playerid, params[])
{
new playerb, seatid, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsACop(playerid) && !IsFBI(playerid) && !IsAGov(playerid) && !IsARES(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer/FBI Agent.");
if(sscanf(params, "ui", playerb, seatid)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /detain [playerid] [seatid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You can't detain someone from this disatance.");
if(!IsPlayerCuffed(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not cuffed.");
if(seatid < 2 || seatid > 3) return SendClientMessage(playerid, COLOR_GREY, "You can only detain people in seats 2 and 3.");
PutPlayerInVehicle(playerb, LastCar[playerid], seatid);
format(string, sizeof(string), "* %s grabs %s from their cuffs and throws him inside the car.", RPN(playerid), RPN(playerb));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
Re: Need help cmd:detain -
Macronix - 10.03.2014
What is the variable "LastCar[playerid]" or what does it do?
Re: Need help cmd:detain -
stundje - 10.03.2014
It is supposed to be the last car which the cop has entered. So it will detain the suspect in the cop car as an example.
AW: Need help cmd:detain -
Macronix - 10.03.2014
Can you show me the code where the last entered car is stored in the variable?
Re: Need help cmd:detain -
stundje - 10.03.2014
new LastCar[MAX_PLAYERS];
LastCar[playerid] = 0;
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
new driver = GetVehicleDriver(vehicleid);
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER && TotalFare[driver] > 0)
{
new money = floatround(TotalFare[driver]);
new message[128];
format(message,sizeof(message),"You paid %d $ to the Taxi driver.", driver,money);
GiveDodMoney(playerid,-money);
TotalFare[driver] = 0;
GiveDodMoney(driver,money);
SendClientMessage(playerid,COLOR_LIGHTBLUE,message);
format(message,sizeof(message),"%s paid you %d $ for the ride.", RPN(playerid) ,money);
SendClientMessage(driver,COLOR_LIGHTBLUE,message);
TotalFare[driver] = 0.00;
IsOnFare[driver] = 0;
KillTimer(faretimer[driver]);
}
for(new i=0; i < MAX_PLAYERS; i++)
if(SweepingJob[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "* You stopped working and you wont be paid.");
SweepingJob[playerid] = 0;
}
if(LicenseTest[playerid])
{
DisablePlayerCheckpoint(playerid);
LicenseTest[playerid] = 0;
CP[playerid] = 0;
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Driving Center: You have left your car, therefore your test has been failed.");
}
if(PlayerInfo[playerid][pFac] == 1 && PlayerInfo[playerid][pFac] == 7 && PlayerInfo[playerid][pFac] == 6)
{
LastCar[playerid] = vehicleid;
}
return 1;
}
AW: Need help cmd:detain -
Macronix - 10.03.2014
Код:
if(PlayerInfo[playerid][pFac] == 1 && PlayerInfo[playerid][pFac] == 7 && PlayerInfo[playerid][pFac] == 6)
This means that the player needs to be in Factions 1, 7 and 6. Is this right? Otherwise you must write || instead of &&
Re: Need help cmd:detain -
stundje - 10.03.2014
That's correct, the command is scripted and the texts does popup, but it won't put someone in the car.
AW: Need help cmd:detain -
Macronix - 10.03.2014
Try to save the LastCar in OnPlayerEnterVehicle or OnPlayerStateChange where you check if newstate is PLAYER_STATE_DRIVER.
Re: Need help cmd:detain -
SkilledMaster - 11.03.2014
Here ya go bud.
Код:
CMD:detain(playerid, params[])
{
if(IsACop(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessageEx(playerid, COLOR_GREY, "You can't do this while you're in a vehicle.");
return 1;
}
new string[128], giveplayerid, seat;
if(sscanf(params, "ud", giveplayerid, seat)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /detain [player] [seatid 1-3]");
if(IsPlayerConnected(giveplayerid))
{
if(seat < 1 || seat > 3)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "The seat ID cannot be above 3 or below 1.");
return 1;
}
if(IsACop(giveplayerid))
{
SendClientMessageEx(playerid, COLOR_GREY, "You can't detain other law enforcement officers.");
return 1;
}
if(IsPlayerInAnyVehicle(giveplayerid))
{
SendClientMessageEx(playerid, COLOR_GREY, "That person is in a car - get them out first.");
return 1;
}
if (ProxDetectorS(8.0, playerid, giveplayerid))
{
if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You cannot detain yourself!"); return 1; }
if(PlayerCuffed[giveplayerid] == 2)
{
new carid = gLastCar[playerid];
if(IsSeatAvailable(carid, seat))
{
new Float:pos[6];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerPos(giveplayerid, pos[3], pos[4], pos[5]);
GetVehiclePos( carid, pos[0], pos[1], pos[2]);
if (floatcmp(floatabs(floatsub(pos[0], pos[3])), 10.0) != -1 &&
floatcmp(floatabs(floatsub(pos[1], pos[4])), 10.0) != -1 &&
floatcmp(floatabs(floatsub(pos[2], pos[5])), 10.0) != -1) return false;
format(string, sizeof(string), "* You were detained by %s .", GetPlayerNameEx(playerid));
SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You detained %s .", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s throws %s in the vehicle.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(giveplayerid, "~r~Detained", 2500, 3);
ClearAnimations(giveplayerid);
TogglePlayerControllable(giveplayerid, false);
IsPlayerEntering{giveplayerid} = true;
PutPlayerInVehicle(giveplayerid, carid, seat);
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That seat isn't available!");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That person isn't cuffed.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, " You're not close enough to the person or your car!");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " You are not a law enforcement officer!");
}
return 1;
}
+Rep if this helped.