/sellweaponlicense - /Detain
#1

Two simple (not simple enough for me ) questions

Uh, firstly, would it be worth my time trying to do a /sellweaponlicense command for Police so that you dont buy the license anywhere, you have to get it from a police officer or Chief of police.. and how would i actually go about doing that?

Secondly (Here comes the hard (for some) simple part)
I have a /detain + /undetain command here

When i cuff the suspect and /detain [id] [seatid] it says their detained but physically, their not. Their still outside the vehicle and standing. Any idea what it is?.. I was thinkging maybe its missing "SetPlayerPos", But i thought i'd ask for someones opinion before i go editing code and making it even worse
Reply
#2

Well. The /setweaponlicense command will vary on how your script was written. Post your /detain command, I'll take a look.
Reply
#3

Sorry, forgot to paste the code..

Код:
new 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)
		{
Everything there including gLastcar from /detain command..

/sellweapon command would derive from this somehow

pawn Код:
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;
    }
I know for a fact you have to remove
Код:
if(GetPlayerCash(playerid) >= 50000)
					{
						GivePlayerCash(playerid,-50000);
But the only thing that confuses me is twisting the code around so it actually gives another person a license and not you.
Reply
#4

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.
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
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.
Thank you. When i become a millionaire i'll donate you a few hundred thousand

P.S will my strcmp /undetain command still work even with /detain being DCMD + SSCANF?
Reply
#6

I don't work with DCMD often so you will need to do all of the defining of DCMD and add the special line under "OnPlayerCommandText". This is what I was able to get working:

pawn Код:
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;
}
You will need to include the SSCANF include file and load it's plugin when you start your server. You will again, need to do the stuff for DCMD. Tell me if it works or not and yes, you should be able to use your undetain command with this. (considering it works)
Reply
#7

Код:
\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
15436
Код:
else return SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
15437
Код:
if(CopOnDuty[playerid] == 1)
15441

Код:
if(sscanf(params, "ud", id, seatid))
15443
Код:
if(!IsPlayerConnected(id))
15445
Код:
if(!IsPlayerInAnyVehicle(id))
15447
Код:
if(id == playerid)
15450
return SendClientMessage(playerid, COLOR_WHITE, "(ERROR) That player is not within your range!");
Reply
#8

Sorry, forgot to define the "new" variables. I fixed the code.
Reply
#9

Still some errors

Код:
\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
Heres all the lines going in order from top to bottom of the error list
Код:
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));
Also i was thinking/looking, The script im using is Carlito's RP.. id doesn't have id or idName etc in it. Should i change "id" to "giveplayerid" and "idName" to "giveplayer" ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)