SA-MP Forums Archive
Arrest Point - 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: Arrest Point (/showthread.php?tid=436949)



Arrest Point - Latisha - 13.05.2013

Hello,

I wanna ask how to create arrest points.
My current scripts
Код:
CMD:arrestpoint(playerid, params[])
{
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
   	if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
	GetPlayerPos(playerid, ap[0], ap[1], ap[2]);
	DestroyDynamic3DTextLabel(apt);
	DestroyPickup(apt2);
	apt = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
	apt2 = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);
	SendClientMessage(playerid, COLOR_WHITE, " You have changed the NYPD's arrest point.");
	return 1;
}
It can only create one arrest point.
Can someone help me?


Re: Arrest Point - Latisha - 13.05.2013

Can someone help me?


Re: Arrest Point - MP2 - 13.05.2013

Not when you bump after less than an hour. Be patient.


Re: Arrest Point - Calabresi - 13.05.2013

Check these lines:

pawn Код:
DestroyDynamic3DTextLabel(apt);
    DestroyPickup(apt2);
    apt = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
    apt2 = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);
You are destroying the previously created text label and pickup when you write the command again. That's why you are able to create only one point. If you delete these lines;

pawn Код:
DestroyDynamic3DTextLabel(apt);
    DestroyPickup(apt2);
You will be able to create multiple points - however, you must be able to destroy something that you've created later. Because of that, I suggest you to script something like this;

pawn Код:
#define MAX_ARREST_POINTS 30 // Defining maximum arrest points.
new ArrestPoints[1][MAX_ARREST_POINTS]; // Creating our variable to store IDs, in case of you need to delete them.
new ArrestPointCount; // To keep how many arrest points have been created.
CMD:arrestpoint(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
        if(ArrestPointCount == MAX_ARREST_POINTS) return SendClientMessage(playerid, COLOR_GREY, "Arrest point limit has been filled!");
    GetPlayerPos(playerid, ap[0], ap[1], ap[2]);
    ArrestPoints[0][ArrestPointCount] = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
    ArrestPoints[1][ArrestPointCount] = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);
    SendClientMessage(playerid, COLOR_WHITE, " You have changed the NYPD's arrest point.");
        ArrestPointCount++;
    return 1;
}
The code above is just for giving the idea.


Re: Arrest Point - Latisha - 13.05.2013

Lemme try, thanks before

___________________________________


warning 203: symbol is never used: "ArrestPointCount"
warning 203: symbol is never used: "ArrestPoints"
warning 204: symbol is assigned a value that is never used: "apt"
warning 204: symbol is assigned a value that is never used: "apt2"

4 warns, how to fix that?


Re: Arrest Point - Calabresi - 13.05.2013

Quote:
Originally Posted by Latisha
Посмотреть сообщение
Lemme try, thanks before

___________________________________


warning 203: symbol is never used: "ArrestPointCount"
warning 203: symbol is never used: "ArrestPoints"
warning 204: symbol is assigned a value that is never used: "apt"
warning 204: symbol is assigned a value that is never used: "apt2"

4 warns, how to fix that?
Did you copy the code I've written or what? Delete "apt" and "apt2" variables from the script.

EDIT: Also replace

pawn Код:
new ArrestPointCount;
with

pawn Код:
new ArrestPointCount = 0;



Re: Arrest Point - Latisha - 13.05.2013

I have to delete this?
Код:
apt = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
apt2 = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);



Re: Arrest Point - Calabresi - 13.05.2013

Quote:
Originally Posted by Latisha
Посмотреть сообщение
I have to delete this?
Код:
apt = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
apt2 = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);
I have already explained the code above. If you want to check if it works, just delete your whole "CMD:arrestpoint" lines and replace with mine.


Re: Arrest Point - Latisha - 13.05.2013

warning 213: tag mismatch
error 032: array index out of bounds (variable "ArrestPoints")
warning 204: symbol is assigned a value that is never used: "apt"
warning 204: symbol is assigned a value that is never used: "apt2"

I used your scripts


Re: Arrest Point - Calabresi - 13.05.2013

Quote:
Originally Posted by Latisha
Посмотреть сообщение
warning 213: tag mismatch
error 032: array index out of bounds (variable "ArrestPoints")
warning 204: symbol is assigned a value that is never used: "apt"
warning 204: symbol is assigned a value that is never used: "apt2"

I used your scripts
Ooops, my bad. I didn't notice the mistake I've made, sorry. Use this:

pawn Код:
#define MAX_ARREST_POINTS 30 // Defining maximum arrest points.
new ArrestPoints[MAX_ARREST_POINTS]; // Creating our variable to store IDs, in case of you need to delete them.
new Text3D:ArrestPointText[MAX_ARREST_POINTS];
new ArrestPointCount; // To keep how many arrest points have been created.
CMD:arrestpoint(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
        if(ArrestPointCount == MAX_ARREST_POINTS) return SendClientMessage(playerid, COLOR_GREY, "Arrest point limit has been filled!");
    GetPlayerPos(playerid, ap[0], ap[1], ap[2]);
    ArrestPointText[ArrestPointCount] = CreateDynamic3DTextLabel("Arrest Point\n{FFFF00}/arrest to arrest a suspect", COLOR_RED, ap[0], ap[1], ap[2], 12);
    ArrestPoints[ArrestPointCount] = CreatePickup(1314, 1, ap[0], ap[1], ap[2]);
    SendClientMessage(playerid, COLOR_WHITE, " You have changed the NYPD's arrest point.");
        ArrestPointCount++;
    return 1;
}
Also, press CTRL-F in the program you use to edit your script and search for "apt" and "apt2". Then delete them.