SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/08/2019, 05:15 PM   #1
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 515
Reputation: 18
Default Dynamic CP

Hello, i'm having a problem with this function.

Basically when a civilian commits a crime, a mapicon and a checkpoint is created and shown to all cops online. Problem is:

Mapicon is shown only to cops (and that's how it should meant to be), but checkpoint is shown to civilians too, which it shouldn't be like this:

What's wrong?

pawn Code:
stock CreateCrimeReport(playerid)
{
    if(!(0 <= playerid < MAX_PLAYERS)) return;

    new iCrimeReport = Iter_Free(InformedRobbery);

    if(iCrimeReport != ITER_NONE)
    {
        Iter_Add(InformedRobbery, iCrimeReport);

        GetPlayerPos(playerid, posx, posy, posz);

        Crimes[iCrimeReport][E_ALPHA] = 0xAA;
        Crimes[iCrimeReport][E_MAP_ICON] = CreateDynamicMapIcon(posx, posy, posz, 0, COLOR_GREY, -1, -1, 0, 1000.0, MAPICON_GLOBAL);
        Crimes[iCrimeReport][E_CHECKPOINT] = CreateDynamicRaceCP(0, posx, posy, posz, posx, posy, posz, 5, -1, -1, -1, 1000, -1, 0);

        Streamer_RemoveArrayData(STREAMER_TYPE_MAP_ICON, Crimes[iCrimeReport][E_MAP_ICON], E_STREAMER_PLAYER_ID, 0);
        Streamer_AppendArrayData(STREAMER_TYPE_CP, Crimes[iCrimeReport][E_CHECKPOINT], E_STREAMER_PLAYER_ID, 0);   

        foreach(new i : Player) if(ReturnPlayerClass(i) == CLASS_LAW)
        {
            Streamer_AppendArrayData(STREAMER_TYPE_MAP_ICON, Crimes[iCrimeReport][E_MAP_ICON], E_STREAMER_PLAYER_ID, i);
            Streamer_AppendArrayData(STREAMER_TYPE_RACE_CP, Crimes[iCrimeReport][E_CHECKPOINT], E_STREAMER_PLAYER_ID, i);
        }
    }
}
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is offline   Reply With Quote
Old 24/08/2019, 07:38 PM   #2
CheezIt
Big Clucker
 
CheezIt's Avatar
 
Join Date: Apr 2017
Posts: 182
Reputation: 17
Default Re: Dynamic CP

Note the playerid parameter. For the map icon you have it set to ID 0, and the checkpoint is set for everyone...

https://github.com/samp-incognito/sa...es-(Map-Icons)
https://github.com/samp-incognito/sa...e-Checkpoints)
__________________
I'd like to bring back my old CNR server that was created from scratch & hosted years ago. I'll host & update everything (including the website & forum). You would pay for hosted tab and help manage the community. PM me if you're interested!
CheezIt is offline   Reply With Quote
Old 24/08/2019, 07:53 PM   #3
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 515
Reputation: 18
Default Re: Dynamic CP

So i have to use -1 on both instead of 0?
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is offline   Reply With Quote
Old 24/08/2019, 10:12 PM   #4
CheezIt
Big Clucker
 
CheezIt's Avatar
 
Join Date: Apr 2017
Posts: 182
Reputation: 17
Default Re: Dynamic CP

Quote:
Originally Posted by KeyOfKey View Post
So i have to use -1 on both instead of 0?
-1 is for everyone
0 is for player with ID 0
__________________
I'd like to bring back my old CNR server that was created from scratch & hosted years ago. I'll host & update everything (including the website & forum). You would pay for hosted tab and help manage the community. PM me if you're interested!
CheezIt is offline   Reply With Quote
Old 25/08/2019, 07:06 AM   #5
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 515
Reputation: 18
Default Re: Dynamic CP

So what?
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is offline   Reply With Quote
Old 25/08/2019, 06:09 PM   #6
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 328
Reputation: 22
Default Re: Dynamic CP

Quote:
Originally Posted by KeyOfKey View Post
So what?
You tested it with your ID as 0?
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 25/08/2019, 07:48 PM   #7
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 515
Reputation: 18
Default Re: Dynamic CP

Yes.
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is offline   Reply With Quote
Old 26/08/2019, 05:57 AM   #8
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 328
Reputation: 22
Default Re: Dynamic CP

So, you got your solution.

Keep that you are ID 0.

In CP the playerid paramater is -1, which -1 means the cp will be shown to everyone.
In Mapicon the playerid paramter is 0, which means it will be only shown to playerid 0, and that ID 0 is you.
So, that's why Mapicon is only been shown to you but not others and CP is shown to everyone because the playerid paramter is setted as -1.

So, the solution is you have to loop to all cops and set -1/0 to cops loop id.
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 26/08/2019, 02:23 PM   #9
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 515
Reputation: 18
Default Re: Dynamic CP

What about if i replace "0" with "65535"?
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is offline   Reply With Quote
Old 26/08/2019, 04:47 PM   #10
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 328
Reputation: 22
Default Re: Dynamic CP

Quote:
Originally Posted by KeyOfKey View Post
What about if i replace "0" with "65535"?
Try using -1 instead '0' and check!
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic CP Ryan50 Scripting Help 8 20/02/2017 09:23 PM
Dynamic Micko123 Scripting Help 1 09/10/2016 08:56 AM
3dtextlabel dynamic or not dynamic help! Dubbystep Scripting Help 0 05/02/2012 05:19 PM
How to get dynamic pos? MS:RP Mason Scripting Help 14 13/01/2012 05:26 PM
dynamic(cp) Blatnoi Help Archive 4 20/12/2010 09:51 AM


All times are GMT. The time now is 10:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.