SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/09/2019, 04:40 PM   #1
Kruno88
Huge Clucker
 
Kruno88's Avatar
 
Join Date: Apr 2014
Posts: 343
Reputation: 56
Default Dynamic Checkpoint help needed

Code:
new CP_robbery[2];
Code:
	CP_robbery[0] = CreateDynamicCP(2030.65906, -1097.66809, 28.66820,3.0,-1,-1,-1,100.0);
	CP_robbery[1] = CreateDynamicCP(2034.05591, -1088.73145, 28.66820,3.0,-1,-1,-1,100.0);
I want a message that says "You just entered checkpoint x" on OnPlayerEnterDynamicCP.

Anybody knows how to do this?
Kruno88 is offline   Reply With Quote
Old 24/09/2019, 04:51 PM   #2
Fuzzy
Big Clucker
 
Join Date: May 2019
Posts: 93
Reputation: 5
Default Re: Dynamic Checkpoint help needed

PHP Code:
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
if (
checkpointid== CP_robbery[0])
{
         
DestroyDynamicCP(CP_robbery[0]);
         
// Your msg here
}
return 
1;

Example
__________________
My Releases:
Tutorial:
Gamemode:
Fuzzy is offline   Reply With Quote
Old 24/09/2019, 05:04 PM   #3
Kruno88
Huge Clucker
 
Kruno88's Avatar
 
Join Date: Apr 2014
Posts: 343
Reputation: 56
Default Re: Dynamic Checkpoint help needed

Quote:
Originally Posted by Fuzzy View Post
PHP Code:
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
if (
checkpointid== CP_robbery[0])
{
         
DestroyDynamicCP(CP_robbery[0]);
         
// Your msg here
}
return 
1;

Example
I want to create a loop which automatically gets which CP id the person is in
I just don't know how
Kruno88 is offline   Reply With Quote
Old 24/09/2019, 05:20 PM   #4
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 121
Reputation: 43
Default Re: Dynamic Checkpoint help needed

You don't need a loop for this. You must simply listen to the OnPlayerEnterDynamicCP callback, which receives both the ID of the player and of the checkpoint, which you can compare against the variable where you create the point.

You can create a switch statement with a case per each Dynamic CP in your server. Example:

PHP Code:
public OnPlayerEnterDynamicCP(playeridcheckpointid) {
    switch (
checkpointid) {
        case 
CP_robbery[0]: {
            
SendClientMessage(playeridcolor"You just entered checkpoint X");
            
// rest of the code for this case
        
}
        case 
CP_robbery[1]: {
            
SendClientMessage(playeridcolor"You just entered checkpoint X");
            
// rest of the code for this case
        
}
    }

Markski is offline   Reply With Quote
Old 24/09/2019, 05:25 PM   #5
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: Dynamic Checkpoint help needed

Quote:
Originally Posted by Markski View Post
You can create a switch statement with a case per each Dynamic CP in your server. Example:

PHP Code:
public OnPlayerEnterDynamicCP(playeridcheckpointid) {
    switch (
checkpointid) {
        case 
CP_robbery[0]: {
            
SendClientMessage(playeridcolor"You just entered checkpoint X");
            
// rest of the code for this case
        
}
        case 
CP_robbery[1]: {
            
SendClientMessage(playeridcolor"You just entered checkpoint X");
            
// rest of the code for this case
        
}
    }

Only constant values are allowed in `case`.
Calisthenics is offline   Reply With Quote
Old 24/09/2019, 06:03 PM   #6
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 121
Reputation: 43
Default Re: Dynamic Checkpoint help needed

Quote:
Originally Posted by Calisthenics View Post
Only constant values are allowed in `case`.
You're correct, I confused it with how dialogs are handled..

In that case, just follow the same logic with if and else's. The point is you need to listen for checkpoint entries in that callback.
Markski is offline   Reply With Quote
Old 25/09/2019, 06:43 AM   #7
Kruno88
Huge Clucker
 
Kruno88's Avatar
 
Join Date: Apr 2014
Posts: 343
Reputation: 56
Default Re: Dynamic Checkpoint help needed

But how do I do that?Because I dont want to use if and else but some other way of doing that.Probobaly trough some loop or something
Kruno88 is offline   Reply With Quote
Old 25/09/2019, 08:40 AM   #8
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: Dynamic Checkpoint help needed

Loop through CP_robbery, check checkpoint id inside loop, do stuff.
Basically Fuzzys example with a surrounding loop and instead of index 0, you use the variable from the loop.
Plastikmensch is offline   Reply With Quote
Old 25/09/2019, 09:28 AM   #9
Kruno88
Huge Clucker
 
Kruno88's Avatar
 
Join Date: Apr 2014
Posts: 343
Reputation: 56
Default Re: Dynamic Checkpoint help needed

Quote:
Originally Posted by Plastikmensch View Post
Loop through CP_robbery, check checkpoint id inside loop, do stuff.
Basically Fuzzys example with a surrounding loop and instead of index 0, you use the variable from the loop.
Sherlock,is that you?
"do stuff"
No code or anything?
Kruno88 is offline   Reply With Quote
Old 25/09/2019, 10:24 AM   #10
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: Dynamic Checkpoint help needed

Quote:
Originally Posted by Kruno88 View Post
Sherlock,is that you?
"do stuff"
No code or anything?
Dude, if you wanna learn then it's ok, if you wanna find a code to copy-paste without even thinking what it is then you're in the wrong place.
Why do u reply with such an attitude to people who helps you?
In the first time i made the code, then i've seen this message and well, no, i won't help who gets that type of attitude, i hate such things.

Quote:
Originally Posted by Plastikmensch View Post
Basically Fuzzys example with a surrounding loop and instead of index 0, you use the variable from the loop.
There's already a code and she told you to add a loop to it, is that so hard to give it a try?
https://wiki.sa-mp.com/wiki/Loops
Make a loop with sizeof(CP_Robbery).
__________________
Jonny 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 Checkpoint bug NealPeteros Scripting Help 10 17/05/2017 08:00 AM
Dynamic Checkpoint Genmetal Scripting Help 2 18/11/2014 10:35 AM
Dynamic DealerShip Needed Please traxrex Help Archive 10 22/08/2010 02:48 AM
Checkpoint help needed security Help Archive 0 24/04/2010 08:42 AM


All times are GMT. The time now is 02:26 AM.


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