12.10.2015, 14:40
Okay so first, on top of your script, somewhere outside a callback, put this:
This creates a variable 'woodmancp' for every player
Now under the OnPlayerCommandText, add your command (I fixed & added some stuff)
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
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...
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
PHP код:
new woodmancp[MAX_PLAYERS];
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(playerid, COLOR_WHITE, "You are not a Woodman");
if(woodmancp[playerid] != 0) return SendClientMessage(playerid, COLOR_WHITE, "You are already working");
if(PlayerToPoint(3.0,playerid,-401.9135,-1419.8245,26.3281)){
SetPlayerCheckpoint(playerid, -416.8940, -1420.9407, 24.2437, 2.0);
woodmancp[playerid] = 1;
}
else return SendClientMessage(playerid, COLOR_WHITE, "You are not at the work location");
}
}
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;
}
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
if(woodmancp[playerid] == 1){
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -396.8735, -1435.6885, 25.7266, 2.0);
AttachPlayerObjectToPlayer(objectplayer, objectid, attachplayer, 1.5, 0.5, 1431, 0, 1.5, 2 );
woodmancp[playerid] = 2;
}
else if(woodmancp[playerid] == 2){
woodmancp[playerid] = 0;
DisablePlayerCheckpoint(playerid);
GivePlayerMoney(5000,playerid);
}
return 1;
}
Hit me up with a profile message if it is still not functioning