) questionsnew gLastCar[MAX_PLAYERS];
if(strcmp(cmd, "/detain", true) ==0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
{
if(CopOnDuty[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) You are not on duty");
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) You can not use this whilst in a car");
return 1;
}
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "(USAGE) /detain [playerid/partofname] [seatid]");
return 1;
}
new carid = gLastCar[playerid];
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) You can not detain yourself");
return 1;
}
tmp = strtok(cmdtext, idx);
new seat = strval(tmp);
if(seat < 1 || seat > 3) { SendClientMessage(playerid, COLOR_GREY, "(ERROR) The seat ID can not be above 3 or below 1"); return 1; }
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "(USAGE) /detain [playerid/partofname] [seatid]");
return 1;
}
if(!ProxDetectorS(8.0, playerid, giveplayerid))
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) That player is not in range");
return 1;
}
if(PlayerCuffed[giveplayerid] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "(INFO) You were detained by %s", sendername);
SendClientMessage(giveplayerid, COLOR_WHITE, string);
format(string, sizeof(string), "(INFO) You detained %s", giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s grabs %s and throws him in the car", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(giveplayerid, "~r~BUSTED", 2500, 3);
ClearAnimations(giveplayerid);
TogglePlayerControllable(giveplayerid, 0);
PutPlayerInVehicle(giveplayerid,carid,seat);
PlayerCuffed[giveplayerid] = 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) That player is not cuffed");
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
}
}//not connected
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
gLastCar[playerid] = GetPlayerVehicleID(playerid);
if(DynamicCars[GetPlayerVehicleID(playerid)-1][CarType] != 1)
{
if(strcmp(cmd, "/buyweaponlicense", true) == 0)
{
if(PlayerToPoint(1.0,playerid,WeaponLicensePosition[X],WeaponLicensePosition[Y],WeaponLicensePosition[Z]))
{
if(GetPlayerVirtualWorld(playerid) == WeaponLicensePosition[World])
{
if(PlayerInfo[playerid][pWepLic] == 0)
{
if(GetPlayerCash(playerid) >= 50000)
{
GivePlayerCash(playerid,-50000);
SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] You can now use weapons legally, within reason of course.");
PlayerInfo[playerid][pWepLic] = 1;
OnPlayerDataSave(playerid);
}
else
{
SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERROR:] You don't have enough money!");
}
}
else
{
SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERROR:] You already have a license!");
}
}
}
else
{
SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERROR:] You are not at the license location!");
}
return 1;
}
if(GetPlayerCash(playerid) >= 50000)
{
GivePlayerCash(playerid,-50000);
|
Okay, I am going to re-write your /detain command using DCMD and SSCANF, as it's what I'm used to. Just give me 10 minutes so I can "decode" the code.
![]() |

dcmd(detain, playerid, params[])
{
new id[MAX_PLAYER_NAME], seatid;
if(!IsPlayerConnected(playerid))
return false;
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
else return SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
if(CopOnDuty[playerid] == 1)
return SendClientMessage(playerid, COLOR_GREY, "(ERROR) You are not on duty");
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_GREY, "(ERROR) You can not use this whilst in a car");
if(sscanf(params, "ud", id, seatid))
return SendClientMessage(playerid, COLOR_WHITE, "(USAGE) /detain [playerid/partofname] [seatid]");
if(!IsPlayerConnected(id))
return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) That player is not connected!");
if(!IsPlayerInAnyVehicle(id))
return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) That player is in another vehicle, get them out first!");
if(id == playerid)
return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) You cannot detain yourself!");
if(!ProxDetectorS(8.0, playerid, id)
return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) That player is not within your range!");
if(seatid < 1 || seatid > 3)
return SendClientMessage(playerid, COLOR_GREY, "(ERROR) The seat ID can not be above 3 or below 1");
if(PlayerCuffed[giveplayerid] > 0)
{
GetPlayerName(id, idName, sizeof(idName));
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "(INFO) You were detained by %s", playerName);
SendClientMessage(id, COLOR_WHITE, string);
format(string, sizeof(string), "(INFO) You detained %s", idName);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s grabs %s and throws them in the car", playerName, idName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(id, "~r~BUSTED", 2500, 3);
ClearAnimations(id);
TogglePlayerControllable(id, false);
PutPlayerInVehicle(giveplayerid, gLastCar[playerid], seat);
PlayerCuffed[giveplayerid] = 1;
}
return 1;
}
\GTa Server\0.3B R2\gamemodes\crp.pwn(15436) : error 029: invalid expression, assumed zero \GTa Server\0.3B R2\gamemodes\crp.pwn(15436) : warning 215: expression has no effect \GTa Server\0.3B R2\gamemodes\crp.pwn(15436) : error 001: expected token: ";", but found "return" \GTa Server\0.3B R2\gamemodes\crp.pwn(15436) : warning 217: loose indentation \GTa Server\0.3B R2\gamemodes\crp.pwn(15437) : warning 225: unreachable code \GTa Server\0.3B R2\gamemodes\crp.pwn(15437) : warning 217: loose indentation \GTa Server\0.3B R2\gamemodes\crp.pwn(15441) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15443) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15445) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15447) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15449) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15450) : error 001: expected token: ")", but found "return" \GTa Server\0.3B R2\gamemodes\crp.pwn(15451) : error 017: undefined symbol "seatid" \GTa Server\0.3B R2\gamemodes\crp.pwn(15453) : error 017: undefined symbol "giveplayerid" \GTa Server\0.3B R2\gamemodes\crp.pwn(15455) : error 017: undefined symbol "id" \GTa Server\0.3B R2\gamemodes\crp.pwn(15455) : error 017: undefined symbol "idName" \GTa Server\0.3B R2\gamemodes\crp.pwn(15455) : error 029: invalid expression, assumed zero \GTa Server\0.3B R2\gamemodes\crp.pwn(15455) : fatal error 107: too many error messages on one line
else return SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
if(CopOnDuty[playerid] == 1)
if(sscanf(params, "ud", id, seatid))
if(!IsPlayerConnected(id))
if(!IsPlayerInAnyVehicle(id))
if(id == playerid)
\crp.pwn(15437) : error 029: invalid expression, assumed zero \crp.pwn(15437) : warning 215: expression has no effect \crp.pwn(15437) : error 001: expected token: ";", but found "return" \crp.pwn(15437) : warning 217: loose indentation \crp.pwn(15438) : warning 225: unreachable code \crp.pwn(15438) : warning 217: loose indentation \crp.pwn(15444) : error 035: argument type mismatch (argument 1) \crp.pwn(15446) : error 035: argument type mismatch (argument 1) \crp.pwn(15448) : error 033: array must be indexed (variable "id") \crp.pwn(15450) : error 035: argument type mismatch (argument 3) \crp.pwn(15451) : error 001: expected token: ")", but found "return" \crp.pwn(15454) : error 017: undefined symbol "giveplayerid" \crp.pwn(15456) : error 035: argument type mismatch (argument 1) \crp.pwn(15456) : error 017: undefined symbol "idName" \crp.pwn(15456) : error 029: invalid expression, assumed zero \crp.pwn(15456) : fatal error 107: too many error messages on one line
else return SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction"); if(CopOnDuty[playerid] == 1) if(!IsPlayerConnected(id)) if(!IsPlayerInAnyVehicle(id)) if(id == playerid) if(!ProxDetectorS(8.0, playerid, id) return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) That player is not within your range!"); if(PlayerCuffed[giveplayerid] > 0) GetPlayerName(id, idName, sizeof(idName));