/work command (strcmp), multi errors. [+REP]
#2

Okay so first, on top of your script, somewhere outside a callback, put this:

PHP код:
new woodmancp[MAX_PLAYERS]; 
This creates a variable 'woodmancp' for every player

Now under the OnPlayerCommandText, add your command (I fixed & added some stuff)
PHP код:
if(strcmp(cmd"/work"true) == 0)
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerInfo[playerid][pJob] != 16) return SendClientMessage(playeridCOLOR_WHITE"You are not a Woodman");
        if(
woodmancp[playerid] != 0) return SendClientMessage(playeridCOLOR_WHITE"You are already working");
        if(
PlayerToPoint(3.0,playerid,-401.9135,-1419.8245,26.3281)){
            
SetPlayerCheckpoint(playerid, -416.8940, -1420.940724.24372.0);
            
woodmancp[playerid] = 1;
        }
        else return 
SendClientMessage(playeridCOLOR_WHITE"You are not at the work location");
    }

Take a look at the new command, I'm sure you can figure out what's going on

Now under OnPlayerConnect callback we have to reset the woodmancp variable to ensure we're working with correct variables at all time

PHP код:
public OnPlayerConnect(playerid){
    
woodmancp[playerid] = 0;
    return 
1;

Then we move on to OnPlayerEnterCheckpoint, basically I based it on whatever the value of woodmancp is, and we change it once they enter a checkpoint! Take a look for yourself...
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(
woodmancp[playerid] == 1){
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0);
        
AttachPlayerObjectToPlayer(objectplayerobjectidattachplayer1.50.5143101.5);
        
woodmancp[playerid] = 2;
    }
    else if(
woodmancp[playerid] == 2){
        
woodmancp[playerid] = 0;
        
DisablePlayerCheckpoint(playerid);
        
GivePlayerMoney(5000,playerid);
    }
    return 
1;

I hope you've been able to fix your code now, and maybe learn something too!
Hit me up with a profile message if it is still not functioning
Reply


Messages In This Thread
/work command (strcmp), multi errors. [+REP] - by EgyptForLife - 12.10.2015, 14:29
Re: /work command (strcmp), multi errors. [+REP] - by Sellize - 12.10.2015, 14:40
Re: /work command (strcmp), multi errors. [+REP] - by bgedition - 12.10.2015, 14:41
Re: /work command (strcmp), multi errors. [+REP] - by ZeMuNaC - 12.10.2015, 14:43
Re: /work command (strcmp), multi errors. [+REP] - by Sellize - 12.10.2015, 14:54
Re: /work command (strcmp), multi errors. [+REP] - by EgyptForLife - 12.10.2015, 15:17

Forum Jump:


Users browsing this thread: 1 Guest(s)