How can I detect this?
#1

PlayerInfo[playerid][Money] ++ 300

I want to make a simple script

Player enters in checkpoint with 0$ (ex)
Players enters in second checkpoint with 300$.
If player has less than 300$ gained before entering in the second checkpoint, will get message "Failed".

How can I detect that?
Reply
#2

Is this what you're looking for?

PHP Code:
#include <a_samp>
new bool:g_CPCheck1[MAX_PLAYERS];
new 
bool:g_CPCheck2[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
    
SetPlayerCheckpoint(playerid2493.9133, -1682.398613.33873.0);/*XYZ Coords*/
    
g_CPCheck1[playerid] = true;
    
/*XYZ Coords*/
    
return 1;
}
 
public 
OnPlayerEnterCheckpoint(playerid)
{
    new 
money GetPlayerMoney(playerid);
    if(
money 300 && g_CPCheck2[playerid])
    {
        
DisablePlayerCheckpoint(playerid);
        return 
SendClientMessage(playerid, -1"Failed");
    }
    if(
money <= && g_CPCheck1[playerid])
    { 
        
GivePlayerMoney(playerid300);
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid2483.9133, -1672.398613.33873.0);
        
SendClientMessage(playerid, -1"Take $300, go to the next checkpoint.");
        
g_CPCheck2[playerid] = true;
        
g_CPCheck1[playerid] = false;
    }
    else
        return 
SendClientMessage(playerid, -1"You must have $0");
    return 
1;

Reply
#3

No, I want to check this.


If player enter"s in checkpoint (I will create the checkpoint cases) his PlayerInfo[playerid][Money] row will be saved.

and if he enters in the second checkpoint, and his PlayerInfo[playerid][Money] row is not increased with 300$, clientmessage will appear.


ex.

I have 1500$ and I enter in second CP with 1799$, clientmessage will appear.
I have 1500$ and I enter in second CP with 1800$, clientmessage WILL NOT appear.
Reply
#4

Forums went off for a while so...

PHP Code:
#include <a_samp> 
new bool:g_CPCheck1[MAX_PLAYERS]; 
new 
bool:g_CPCheck2[MAX_PLAYERS]; 
public 
OnPlayerSpawn(playerid

    
SetPlayerCheckpoint(playerid2493.9133, -1682.398613.33873.0);/*XYZ Coords*/ 
    
g_CPCheck1[playerid] = true
    return 
1

new 
money;
 
public 
OnPlayerEnterCheckpoint(playerid

    if(
g_CPCheck1[playerid]) 
    {  
        
money GetPlayerMoney(playerid); 
        
DisablePlayerCheckpoint(playerid); 
        
SetPlayerCheckpoint(playerid2483.9133, -1672.398613.33873.0); 
        
SendClientMessage(playerid, -1"I just saved your money, remember."); 
        
g_CPCheck2[playerid] = true
        
g_CPCheck1[playerid] = false
        return 
1;
    } 
    
    new 
currentmoney GetPlayerMoney(playerid);
    if(
g_CPCheck2[playerid] && currentmoney money 300)
    { 
        
DisablePlayerCheckpoint(playerid); 
        return 
SendClientMessage(playerid, -1"clientmessage will appear"); 
    } 
    else 
        return 
SendClientMessage(playerid, -1"clientmessage WILL NOT appear"); 

EDIT:

Oh and...

Quote:
Originally Posted by Zeus666
View Post
If player enter"s in checkpoint (I will create the checkpoint cases) his PlayerInfo[playerid][Money] row will be saved.
You can't define checkpoints, it's not like pickups, that's why I'm using boolean variables, there can be other ways but not to define them internally.
Reply
#5

Is this good?

PHP Code:
        case 1:
        {
            if((
MedicJob[playerid] != 1) && (pInfo[playerid][pSkin] != 33)) return SendClientMessage(playerid, -1"Not medic!");
            {
                
DisablePlayerCheckpoint(playerid);
                
SetPlayerCheckpoint(playerid275.4052,1863.5951,8.75782.0);
                
SendClientMessage(playerid, -1"yr.");
                
SendClientMessage(playerid,-1,"y.");
                 
MedicJob[playerid] = 2;
                
CP[playerid] = 0;
                
zombieskilled pInfo[playerid][ZombiesKilled];
            }
        }
        case 
2:
        {
            if((
MedicJob[playerid] == 2) && (CP[playerid] != 0)) return SendClientMessage(playerid, -1"y!");
            if(
pInfo[playerid][ZombiesKilled] > zombieskilled)
            {
                
DisablePlayerCheckpoint(playerid);
                
SendClientMessage(playerid, -1"y");
                
SendClientMessage(playerid, -1"y");
                
MedicJob[playerid] = 0;
                
CP[playerid] = 0;
                
ApplyActorAnimation(Actors[8], "DEALER""DEALER_DEAL",4.1,0,0,0,1,1);
                
ApplyActorAnimation(playerid"DEALER""DEALER_DEAL",4.1,0,0,0,1,1);
                
defer ResetAction(playeridACTION_ANIMATION);
            }
            else return 
SendClientMessage(playerid,-1"y");
        } 
Reply
#6

Well... The code yeah why? It shouldn't give you any warnings/errors.

Tell me what you're trying to do concretely with zombies etcetera.
Reply
#7

Quote:
Originally Posted by TheToretto
View Post
Well... The code yeah why? It shouldn't give you any warnings/errors.

Tell me what you're trying to do concretely with zombies etcetera.
I want to check playerInfo value,

I want to save it's value when enters in CP
and I want to check it if it's greater than the first value he entered
Reply
#8

Yes it is correct, but pInfo[playerid][ZombiesKilled] value is both the first checkpoint's and the after checkpoint.
If you wan't to skip that, reset the variable

pawn Code:
zombieskilled = pInfo[playerid][ZombiesKilled];
pInfo[playerid][ZombiesKilled] = 0;
because basically on the if statement you got here:
pawn Code:
if(pInfo[playerid][ZombiesKilled] > zombieskilled)
If you kill just one zombie after the first checkpoint, it will be true.
Reply
#9

Quote:
Originally Posted by TheToretto
View Post
Yes it is correct, but pInfo[playerid][ZombiesKilled] value is both the first checkpoint's and the after checkpoint.
If you wan't to skip that, reset the variable

pawn Code:
zombieskilled = pInfo[playerid][ZombiesKilled];
pInfo[playerid][ZombiesKilled] = 0;
because basically on the if statement you got here:
pawn Code:
if(pInfo[playerid][ZombiesKilled] > zombieskilled)
If you kill just one zombie after the first checkpoint, it will be true.
But I don't want to set it at =0;
Reply
#10

Quote:
Originally Posted by Zeus666
View Post
But I don't want to set it at =0;
Well... Don't. Your code is fine yep.
Reply
#11

Quote:
Originally Posted by TheToretto
View Post
Well... Don't. Your code is fine yep.
I get errors about undefined symbol zombieskilled

When i added new zombieskilled; it gave me a lot of more errors about ysi.....
Reply
#12

Show those errors? Makes no sense..
Reply
#13

Quote:
Originally Posted by TheToretto
View Post
Show those errors? Makes no sense..
PHP Code:
(2923) : error 017undefined symbol "zombieskilled"
(2923) : warning 215expression has no effect
(2929) : error 017undefined symbol "zombieskilled" 
PHP Code:
zombieskilled pInfo[playerid][ZombiesKilled];
if(
pInfo[playerid][ZombiesKilled] > zombieskilled
Reply
#14

Make it global. (By the way I see nothing related to YSI's Library)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)