/SetPlayerScore help
#1

Some days ago i posted a thread that i need help with setplayerscore. I didn't get any answer that worked, so I will try again.

I am currently making a trucking server, and when people finish a mission, they are going to get +1 score. And I wont figure out how to make that. So i would appreciate help a lot. +1 to the one that works.
Reply
#2

Use.
Quote:

SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);

Give me your full mission code if you want me to add it.
Reply
#3

pawn Код:
SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
Also maybe stock GivePlayerScore
pawn Код:
stock GivePlayerScore(playerid,amount);
{
    return SetPlayerScore(playerid,GetPlayerScore(playerid)+amount);
}
Reply
#4

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
Use.

Give me your full mission code if you want me to add it.
Im not sure what of it that is the mission code so i'll give you all of it.


{"Deliver Holy Water from LVA Freight Depot to LVA Church", true, 250, 1701.9475,940.5465,10.8203, 1496.2524,772.1427,10.8203},
{"Deliver of Junk Car Parts from LVA Freight Depot to Shody Ottos", true, 500, 1701.9475,940.5465,10.8203, 1727.6351,1812.1750,10.8203},
{"Deliver Drills From LS Dock Warehouse 2 To Whetstone Mine", true, 9000, 2777.9772949219, -2455.0886230469, 13.285285949707, -1875.4030761719, -1688.1228027344, 21.399225234985},
{"Deliver Top Secret Devices From Randolf Industrial Estate To Area 69", true, 5000, 1594.1290283203, 724.00372314453, 10.469537734985, 134.54122924805, 1945.7899169922, 19.001808166504},
{"Deliver Boxes From LV Depot To SF Depot", true, 7500, 1723.5736083984, 979.20190429688, 10.469537734985, -2129.4470214844, -84.854187011719, 34.969539642334},
{"Deliver Propellers From Ls Dock Warehouse 1 To Verdant Meadows", true, 8000, 2777.7497558594, -2417.4836425781, 13.285341262817, 377.30389404297, 2534.0485839844, 16.250215530396},
{"Deliver Soldiers Mail From Area 69 To 5 Tree Logistics", true, 6500, 134.54122924805, 1945.7899169922, 19.001808166504, -493.13043212891, -514.57434082031, 25.167068481445},
{"Deliver Landing Gears From 5 Tree Logistics To Las Venturas Airport", true, 8000, -493.13043212891, -514.57434082031, 25.167068481445, 1627.9038085938, 1611.8803710938, 20.285793304443},
{"Deliver Oxegen Canisters From RS Haul To SF Air", true, 7000, -83.956573486328, -1126.0145263672, 0.73391342163086, -1447.4144287109, -437.23773193359, 5.5075283050537},
{"Deliver Radars From Verdant Meadows To San Fierro Airport", true, 8500, 377.30389404297, 2534.0485839844, 16.250215530396, -1447.4144287109, -437.23773193359, 5.5075283050537}
};
Reply
#5

Thats not the mission code, you should add the function i gave you at the last checkpoint or whatever of your mission code.
Reply
#6

public OnPlayerFinishMission(playerid)
{
SendClientMessage(playerid, 0x00FF00FF, "You have delivered the load!");
return 1;
}

Is it possible to add it somewhere there?
Reply
#7

If that is your last message when you finnish your mission, then add it there. Replace it with this.
Quote:

public OnPlayerFinishMission(playerid)
{
SendClientMessage(playerid, 0x00FF00FF, "You have delivered the load!");
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
return 1;
}

Reply
#8

Thanks alot, it worked. But the score doesn't get saved when i relogg. Anyone got any idea how to fix?
Reply
#9

No problem. Glad it worked.
For saving, try this out. Keep in mind that its not tested because im out of home.

PHP код:
stock SavePlayerScore(playerid,score);
{
        new 
name[MAX_PLAYER_NAME], scorestring[64];
        
GetPlayerNameplayeridnamesizeof(name) );
        
score GetPlayerScoreplayerid );
        
formatstringsizeof(string), "%s.score" );
        new 
File:userfile fopenstringio_write );
        
formatstringsizeof(string), "%i",score );
        
fwriteuserfilestring );
        
fcloseuserfile );
        return 
1;
}
stock LoadPlayerScore(playerid,score);
{
        new 
name[MAX_PLAYER_NAME], string[64];
        
GetPlayerNameplayeridnamesizeof(name) );
        
formatstringsizeof(string), "%s.score" );
        if( !
fexist(string) ) return true;
        new 
File:userfile fopenstringio_read );
        
freaduserfilestring );
        
fcloseuserfile );
        
SetPlayerScoreplayeridstrval(string) );
        return 
1;

So, under OnPlayerConnect add:
PHP код:
LoadPlayerScore(playerid,score); 
And, under OnPlayerDisconnect add:
PHP код:
SavePlayerScore(playerid,score); 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)