/SetPlayerScore help -
[NOR]John - 05.01.2012
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.
Re: /SetPlayerScore help -
Mrki_Drakula - 05.01.2012
Use.
Quote:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
|
Give me your full mission code if you want me to add it.
Re: /SetPlayerScore help -
[MG]Dimi - 05.01.2012
pawn Код:
SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
Also maybe stock GivePlayerScore
pawn Код:
stock GivePlayerScore(playerid,amount);
{
return SetPlayerScore(playerid,GetPlayerScore(playerid)+amount);
}
Re: /SetPlayerScore help -
[NOR]John - 05.01.2012
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}
};
Re: /SetPlayerScore help -
Mrki_Drakula - 05.01.2012
Thats not the mission code, you should add the function i gave you at the last checkpoint or whatever of your mission code.
Re: /SetPlayerScore help -
[NOR]John - 05.01.2012
public OnPlayerFinishMission(playerid)
{
SendClientMessage(playerid, 0x00FF00FF, "You have delivered the load!");
return 1;
}
Is it possible to add it somewhere there?
Re: /SetPlayerScore help -
Mrki_Drakula - 05.01.2012
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;
}
|
Re: /SetPlayerScore help -
[NOR]John - 05.01.2012
Thanks alot, it worked. But the score doesn't get saved when i relogg. Anyone got any idea how to fix?
Re: /SetPlayerScore help -
Mrki_Drakula - 05.01.2012
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], score, string[64];
GetPlayerName( playerid, name, sizeof(name) );
score = GetPlayerScore( playerid );
format( string, sizeof(string), "%s.score" );
new File:userfile = fopen( string, io_write );
format( string, sizeof(string), "%i",score );
fwrite( userfile, string );
fclose( userfile );
return 1;
}
stock LoadPlayerScore(playerid,score);
{
new name[MAX_PLAYER_NAME], string[64];
GetPlayerName( playerid, name, sizeof(name) );
format( string, sizeof(string), "%s.score" );
if( !fexist(string) ) return true;
new File:userfile = fopen( string, io_read );
fread( userfile, string );
fclose( userfile );
SetPlayerScore( playerid, strval(string) );
return 1;
}
So, under OnPlayerConnect add:
PHP код:
LoadPlayerScore(playerid,score);
And, under OnPlayerDisconnect add:
PHP код:
SavePlayerScore(playerid,score);