SA-MP Forums Archive
[HELP]Dcmd_Setscore - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Dcmd_Setscore (/showthread.php?tid=198588)



[HELP]Dcmd_Setscore - Tessar - 12.12.2010

Hey guys,
I made myself a /setscore command. When i type /setscore 999 it says i have set my score to 0. Can you also make this save so when i log in and log out it stays.

Код:
dcmd_setscore(playerid, params[])
{
	new givePlayer, pName[24], ReturnUserName[24], str[128], score;
	if(PlayerInfo[playerid][AdminLevel] < 4)
	{
		SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
		return 1;
	}
	if(sscanf(params, "u", givePlayer, score))
	{
		SendClientMessage(playerid, COLOR_GRAD1,"Usage: /setscore [playerid] [score]");
	}
	if(!IsPlayerConnected(givePlayer))
	{
		SendClientMessage(playerid, COLOR_RED, "Invalid playerid");
	}
	if(score <0 || score > 999999)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "The score cannot be lower than 0 and be higher than 999999");
	}
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(givePlayer, ReturnUserName, sizeof(ReturnUserName));

	SetPlayerScore(givePlayer, score);
	format(str, sizeof(str), "**(Admin)** %s (ID: %d) has set %s (ID: %d) score to %d.", pName, playerid, ReturnUserName, givePlayer, score);
	SendmAdminMsg(COLOR_LIGHTRED, str);
	return 1;
}
Thanks.


Re: [HELP]Dcmd_Setscore - blackwave - 12.12.2010

Quote:

SetPlayerHealth(givePlayer, score);

lol

Try:
pawn Код:
SetPlayerScore(GetPlayerScore(givePlayer) + score);
switch with SetPlayerHealth, on my quote


Re: [HELP]Dcmd_Setscore - Kidemo - 12.12.2010

pawn Код:
dcmd_setscore(playerid, params[])
{
    new givePlayer, pName[24], ReturnUserName[24], str[128], score;
    if(PlayerInfo[playerid][AdminLevel] < 4)
    {
        SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
        return 1;
    }
    if(sscanf(params, "u", givePlayer, score))
    {
        SendClientMessage(playerid, COLOR_GRAD1,"Usage: /setscore [playerid] [score]");
    }
    if(!IsPlayerConnected(givePlayer))
    {
        SendClientMessage(playerid, COLOR_RED, "Invalid playerid");
    }
    if(score <0 || score > 999999)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "The score cannot be lower than 0 and be higher than 999999");
    }
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(givePlayer, ReturnUserName, sizeof(ReturnUserName));

    SetPlayerScore(GetPlayerScore(givePlayer) + score);
    format(str, sizeof(str), "**(Admin)** %s (ID: %d) has set %s (ID: %d) score to %d.", pName, playerid, ReturnUserName, givePlayer, score);
    SendmAdminMsg(COLOR_LIGHTRED, str);
    return 1;
}



Re: [HELP]Dcmd_Setscore - Tessar - 12.12.2010

Thanks I finally found that Now how would I make it save?


Re: [HELP]Dcmd_Setscore - Kidemo - 12.12.2010

pawn Код:
format(file,sizeof(file),"MyAdmin/Scores/%s.txt",n);
something like that

thats if ur making a admin system

PHP код:
If not check the scripting tutorials for how to make something save :) 



Re: [HELP]Dcmd_Setscore - Tessar - 12.12.2010

Quote:
Originally Posted by Kidemo
Посмотреть сообщение
pawn Код:
format(file,sizeof(file),"MyAdmin/Scores/%s.txt",n);
something like that

thats if ur making a admin system

PHP код:
If not check the scripting tutorials for how to make something save :) 
I mean to add in the player file
E.G:
Код:
enum pInfo
{
AdminLevel,
}
Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][AdminLevel] = dini_Int(pFile, "AdminLevel");
Like that but linked with the command. Once the command is type it will save the score into the pInfo file.