ID 0 problem
#1

So,i am making trucking server and i have problem with this timer.

PHP код:
forward unloading(playerid);
public 
unloading(playerid)
{
    new 
gString[128];//A new string for storage
    
new playerscore;
    new 
moneymsg[20];
    
TogglePlayerControllable(playerid, 1);
    
SendClientMessage(playerid, COLOR_GREEN, "Well done! You completed the mission!");//sends the player a message
    
format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);//formats the message
    
SendClientMessageToAll(COLOR_GREEN, gString);//sends everyone message saying player completed mission
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
    
playerscore = GetPlayerScore(playerid);
    
SetPlayerScore(playerid, playerscore+1);
    
GivePlayerMoney(playerid, iPay[playerid]);
    
format(moneymsg, sizeof(moneymsg), "~y~+%d~g~$", iPay[playerid]);
    
GameTextForPlayer(playerid, moneymsg, 5000, 1);
    if(
PlayerInfo[playerid][pCompany] == 1)
    {
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 3000$");
        
GivePlayerMoney(playerid, 3000);
    }
    else if(
PlayerInfo[playerid][pCompany] == 2)
    {
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 6000$");
        
GivePlayerMoney(playerid, 6000);
    }
    else if(
PlayerInfo[playerid][pCompany] == 3)
    {
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 12000$");
        
GivePlayerMoney(playerid, 12000);
    }
    return 
1;
} 
Unloading works perfect before if statement. if(PlayerInfo[playerid][pCompany] == 1) etc. only checks for ID 0, it's seems that for other players only works this part

PHP код:
public unloading(playerid)
{
    new 
gString[128];//A new string for storage
    
new playerscore;
    new 
moneymsg[20];
    
TogglePlayerControllable(playerid, 1);
    
SendClientMessage(playerid, COLOR_GREEN, "Well done! You completed the mission!");//sends the player a message
    
format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);//formats the message
    
SendClientMessageToAll(COLOR_GREEN, gString);//sends everyone message saying player completed mission
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
    
playerscore = GetPlayerScore(playerid);
    
SetPlayerScore(playerid, playerscore+1);
    
GivePlayerMoney(playerid, iPay[playerid]);
    
format(moneymsg, sizeof(moneymsg), "~y~+%d~g~$", iPay[playerid]);
    
GameTextForPlayer(playerid, moneymsg, 5000, 1);
} 
I have forwarded

PHP код:
forward unloading(playerid); 
Other codes:

Loading timer:

PHP код:
forward loading(playerid);
public 
loading(playerid)
{
    
TogglePlayerControllable(playerid, 1);
    
SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
    
SendClientMessage(playerid, COLOR_ORANGE, "Loaded. Please head to the second checkpoint!");//sends message
    
MissionStatus[playerid] = 2;//sets the players mission status
    
return 1;
} 
Checkpoint:

PHP код:
stock CheckpointEntered(playerid)
{
    new 
vID = GetPlayerVehicleID(playerid);//Explained earlier
    
if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
    
if(MissionStatus[playerid] == 1)//checks the players mission status
    
{
        
GameTextForPlayer(playerid, "~g~loading...", 5000, 1);
        
TogglePlayerControllable(playerid, false);
        
DisablePlayerCheckpoint(playerid);
        
SetTimerEx("loading",5000,false,"i",playerid);
    }
    else if(
MissionStatus[playerid] == 2)//checks the mission status of the player
    
{
        
GameTextForPlayer(playerid, "~g~unloading...", 4000, 1);
        
DisablePlayerCheckpoint(playerid);
        
SetTimerEx("unloading",6000,false,"i",playerid);
        
TogglePlayerControllable(playerid, false);
    }
    return 
1;
} 
Please help
Reply
#2

It could probably be because your pCompany Array is at 0 or over 3, Your code only checks it if it is between 1 - 3.
I have re-write your code and add a print function show us what it prints:

PHP код:
forward unloading(playerid); 
public 
unloading(playerid) 
{ 
    new 
gString[128], moneymsg[20], playerscore = GetPlayerScore(playerid);
    
TogglePlayerControllable(playerid, 1); 
    
SendClientMessage(playerid, COLOR_GREEN, "Well done! You completed the mission!");//sends the player a message 
    
format(gString, sizeof gString, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);//formats the message 
    
SendClientMessageToAll(COLOR_GREEN, gString);//sends everyone message saying player completed mission 
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0' 
     
    
SetPlayerScore(playerid, playerscore + 1 ); 
    
GivePlayerMoney(playerid, iPay[playerid]); 
    
format(moneymsg, sizeof moneymsg, "~y~+%d~g~$", iPay[playerid]); 
    
GameTextForPlayer(playerid, moneymsg, 5000, 1);

    
printf("Array pCompany: %i", PlayerInfo[playerid][pCompany]); // added for debugging

    
if(PlayerInfo[playerid][pCompany] == 1) 
    { 
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 3000$"); 
        
GivePlayerMoney(playerid, 3000); 
    } 
    else if(
PlayerInfo[playerid][pCompany] == 2) 
    { 
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 6000$"); 
        
GivePlayerMoney(playerid, 6000); 
    } 
    else if(
PlayerInfo[playerid][pCompany] == 3) 
    { 
        
SendClientMessage(playerid, COL_POSITIVE, "Company bonus money: 12000$"); 
        
GivePlayerMoney(playerid, 12000); 
    } 
    return 
true; 
} 
Reply


Forum Jump:


Users browsing this thread: