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(playerid1);
    
SendClientMessage(playeridCOLOR_GREEN"Well done! You completed the mission!");//sends the player a message
    
format(gString512"%s has completed mission: %s"pName(playerid), iMissionText[playerid]);//formats the message
    
SendClientMessageToAll(COLOR_GREENgString);//sends everyone message saying player completed mission
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
    
playerscore GetPlayerScore(playerid);
    
SetPlayerScore(playeridplayerscore+1);
    
GivePlayerMoney(playeridiPay[playerid]);
    
format(moneymsgsizeof(moneymsg), "~y~+%d~g~$"iPay[playerid]);
    
GameTextForPlayer(playeridmoneymsg50001);
    if(
PlayerInfo[playerid][pCompany] == 1)
    {
        
SendClientMessage(playeridCOL_POSITIVE"Company bonus money: 3000$");
        
GivePlayerMoney(playerid3000);
    }
    else if(
PlayerInfo[playerid][pCompany] == 2)
    {
        
SendClientMessage(playeridCOL_POSITIVE"Company bonus money: 6000$");
        
GivePlayerMoney(playerid6000);
    }
    else if(
PlayerInfo[playerid][pCompany] == 3)
    {
        
SendClientMessage(playeridCOL_POSITIVE"Company bonus money: 12000$");
        
GivePlayerMoney(playerid12000);
    }
    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(playerid1);
    
SendClientMessage(playeridCOLOR_GREEN"Well done! You completed the mission!");//sends the player a message
    
format(gString512"%s has completed mission: %s"pName(playerid), iMissionText[playerid]);//formats the message
    
SendClientMessageToAll(COLOR_GREENgString);//sends everyone message saying player completed mission
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
    
playerscore GetPlayerScore(playerid);
    
SetPlayerScore(playeridplayerscore+1);
    
GivePlayerMoney(playeridiPay[playerid]);
    
format(moneymsgsizeof(moneymsg), "~y~+%d~g~$"iPay[playerid]);
    
GameTextForPlayer(playeridmoneymsg50001);

I have forwarded

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

Loading timer:

PHP код:
forward loading(playerid);
public 
loading(playerid)
{
    
TogglePlayerControllable(playerid1);
    
SetPlayerCheckpoint(playeridunx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
    
SendClientMessage(playeridCOLOR_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(playeridCOLOR_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..."50001);
        
TogglePlayerControllable(playeridfalse);
        
DisablePlayerCheckpoint(playerid);
        
SetTimerEx("loading",5000,false,"i",playerid);
    }
    else if(
MissionStatus[playerid] == 2)//checks the mission status of the player
    
{
        
GameTextForPlayer(playerid"~g~unloading..."40001);
        
DisablePlayerCheckpoint(playerid);
        
SetTimerEx("unloading",6000,false,"i",playerid);
        
TogglePlayerControllable(playeridfalse);
    }
    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(playerid1); 
    
SendClientMessage(playeridCOLOR_GREEN"Well done! You completed the mission!");//sends the player a message 
    
format(gStringsizeof gString"%s has completed mission: %s"pName(playerid), iMissionText[playerid]);//formats the message 
    
SendClientMessageToAll(COLOR_GREENgString);//sends everyone message saying player completed mission 
    
MissionStatus[playerid] = 0;//sets the mission status of the player to '0' 
     
    
SetPlayerScore(playeridplayerscore ); 
    
GivePlayerMoney(playeridiPay[playerid]); 
    
format(moneymsgsizeof moneymsg"~y~+%d~g~$"iPay[playerid]); 
    
GameTextForPlayer(playeridmoneymsg50001);

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

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

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)