pvar help
#1

I'm trying to store load name and load pay in pvars since i can't use them in different stocks:

This is the 1st stock where i set pvars:

pawn Код:
stock StartTruckerJob(playerid)
{
    MissionStatus[playerid] = 1;
    Player[playerid][Delivering] = true;
    new MisRand = random(sizeof(TruckerDeliveries));
    new Float:x, Float:y, Float:z;
    x = TruckerDeliveries[MisRand][LoadX];
    y = TruckerDeliveries[MisRand][LoadY];
    z = TruckerDeliveries[MisRand][LoadZ];
    unx[playerid] = TruckerDeliveries[MisRand][UnloadX];
    uny[playerid] = TruckerDeliveries[MisRand][UnloadY];
    unz[playerid] = TruckerDeliveries[MisRand][UnloadZ];
    iPay[playerid] = TruckerDeliveries[MisRand][Pay];
    SetPlayerCheckpoint(playerid, x, y, z, 7);
    SendClientMessage(playerid, -1, "* Trucker job "GREEN"started. "WHITE"Type "RED"/stopwork "WHITE"to stop delivering items.");
    new String[125];
    format(String, sizeof(String), "* Deliver "ORANGE_RED"%s "WHITE"| Earnings: "GREEN"%s", TruckerDeliveries[MisRand][LoadName], formatInt(TruckerDeliveries[MisRand][Pay]));
    SendClientMessage(playerid, -1, String);
    SetPVarInt(playerid, "TruckLoadName", TruckerDeliveries[MisRand][LoadName]);
    SetPVarInt(playerid, "DeliverPay", TruckerDeliveries[MisRand][Pay]);
    return 1;
}
And this is the 2nd where i retrieve them using getpvar:

pawn Код:
stock UnLoadTruck(playerid)
{
    TogglePlayerControllable(playerid,1);
    Player[playerid][Delivering] = false;
    DisablePlayerCheckpoint(playerid);
    GivePlayerMoney(playerid, iPay[playerid]);
    SetMoneyInfo(playerid, iPay[playerid], true, 2000);
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    Player[playerid][Deliveries] ++;
    Player[playerid][EarnedFromDeliveries] += iPay[playerid];
    SendNearbyMessage(playerid, 30.0, -1, "* "ORANGE_RED"%s (%d) "WHITE"delivered "ORANGE_RED"%d "WHITE"and earned "GREEN"%s.", ReturnPlayerName(playerid), playerid, GetPVarInt(playerid, "TruckLoadName"), GetPVarInt(playerid, "formatInt(DeliverPay)"));
    new string[100];
    format(string, sizeof(string), "Delivery completed. Earned ~g~%s.", formatInt(iPay[playerid]));
    ShowPlayerFooter(playerid, string);
    MissionStatus[playerid] = 0;
    return 1;
}
Problem is: DeliverPay shows correct ammount of money earned, truckloadname pvar no. It shows: Kinder_Clans delivered 66 and earned "money ammount".

Why?
Reply
#2

Is this a fs? IF IT a gamemode you can use it as array.
Reply
#3

Is a gamemode. Example of array? I have it already.
Reply
#4

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Is a gamemode. Example of array? I have it already.
You put the product name inside. However you want to name it. Then use it as names to stores the names inside of it. and you can use it for lately when the player done the mission. from example. It's in trucking gamemode as a example. You don't need PVar. Use it as array where you can store it all. on one line. But if you using another fs you also now can use PVar to pass it on to another fs or main gamemode.

for example for one line in array
1, mean Mission ID and others that you know.
Код:
{1, 2054.6843,1928.2374,12.1540, "Visage", "Cash", 2492.5366,2773.2190,10.80422, "Military Aviation Fuel Depot", 1500},
Reply
#5

Is the exactly thing im doing:

pawn Код:
enum TruckerJobLocations
{
    ID,
    LoadName[128],
    Float:LoadX,
    Float:LoadY,
    Float:LoadZ,
    Float:UnloadX,
    Float:UnloadY,
    Float:UnloadZ,
    Pay
}
I tried already in that way, doesn't work if i put LoadName in a different stock.

As u can see, in StartTruckerJob stock name works correctly, but when the player finished the deliver, doesn't work.
Reply
#6

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Is the exactly thing im doing:

pawn Код:
enum TruckerJobLocations
{
    ID,
    LoadName[128],
    Float:LoadX,
    Float:LoadY,
    Float:LoadZ,
    Float:UnloadX,
    Float:UnloadY,
    Float:UnloadZ,
    Pay
}
I tried already in that way, doesn't work if i put LoadName in a different stock.

As u can see, in StartTruckerJob stock name works correctly, but when the player finished the deliver, doesn't work.
Show me part of your enum
Reply
#7

pawn Код:
new TruckerDeliveries[][TruckerJobLocations] =
{
    {0, "Beer from Red County Brewery to Bone County Diner", -24.4073, -281.8898,5.9985, -305.4319, 1315.6797, 54.6189, 5980},
    {1, "Fuel from LV Oil Refinery to LV Dirtring", 266.8981, 1416.5417, 10.2001, 1097.5164, 1741.7422, 10.5474, 5700},
    {2, "Vehicle Parts from SF Airport ATC to Wang Cars", -1268.8223, 13.6925, 14.8682, -1986.3477, 253.9728, 35.8985, 3000},
    {3, "Fuel from SF Oil Refinery to RS Haul", -1016.3634, -688.2434, 32.7284, -55.3397, -1138.2479, 0.8052, 18770}
};
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
new TruckerDeliveries[][TruckerJobLocations] =
{
{0, "Beer from Red County Brewery to Bone County Diner", -24.4073, -281.8898,5.9985, -305.4319, 1315.6797, 54.6189, 5980},
{1, "Fuel from LV Oil Refinery to LV Dirtring", 266.8981, 1416.5417, 10.2001, 1097.5164, 1741.7422, 10.5474, 5700},
{2, "Vehicle Parts from SF Airport ATC to Wang Cars", -1268.8223, 13.6925, 14.8682, -1986.3477, 253.9728, 35.8985, 3000},
{3, "Fuel from SF Oil Refinery to RS Haul", -1016.3634, -688.2434, 32.7284, -55.3397, -1138.2479, 0.8052, 18770}
};
You need to use it as
Код:
TruckerDeliveries[MisRand][LoadName]
Код:
SendNearbyMessage(playerid, 30.0, -1, "%s", TruckerDeliveries[MisRand][LoadName]);
Cause you already got itside of your array. u don't need to pass it on.
Reply
#9

Ok but as u can see from StartTruckerJob stock, i'm using the random function to select random delivery:

pawn Код:
new MisRand = random(sizeof(TruckerDeliveries));
If i use it as u said in the second stock, it will not work. Already tried.
Reply
#10

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Ok but as u can see from StartTruckerJob stock, i'm using the random function to select random delivery:

pawn Код:
new MisRand = random(sizeof(TruckerDeliveries));
If i use it as u said in the second stock, it will not work. Already tried.
You can try and look at this
Код:
enum pInfo
{
    StartingPoint,
    EndingPoint,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
First Load:
Код:
    PlayerInfo[playerid][StartingPoint] = MisRand;
    PlayerInfo[playerid][MissionID] = MisRand;
Second Load:

Код:
forward Trucker2(playerid);
public Trucker2(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pConvoy] == PlayerInfo[playerid][pConvoy])
        {
            if(IsPlayerConnected(i)) 
            {
	            DisablePlayerCheckpoint(playerid);
	            new end = PlayerInfo[playerid][StartingPoint];
                new End = PlayerInfo[playerid][StartingPoint];
             	PlayerInfo[playerid][EndingPoint] = end; 
               	TogglePlayerControllable(playerid, 1);
            	SetPlayerCheckpoint(playerid, trucker[end][ux], trucker[end][uy], trucker[end][uz], 10);
             	truck_PlayerJob[playerid] = 2;
                new workmission2[250];
                format(workmission2,sizeof(workmission2), "~w~Now deliver Head To ~r~%s ~w~To Unload The ~y~%s", trucker[End][ulpname], trucker[end][loadname]);
                PlayerTextDrawSetString(playerid, work[playerid], workmission2);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)