[Question] How to give score?
#1

Hi. I'm trying to make a filterscript where someone can /givescore.
This means he gives his own score to someone else, just like giving money.
I've tried everything but not I have no idea what to do.

Can someone please help me with this?
Reply
#2

Using sscanf?
Reply
#3

Код:
dcmd_givescore(playerid, params[])
{
	new
		giveplayerid,
		amount,
                gscore,
                score;

	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givescore         [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else if (amount > GetPlayerScore(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds");
	else
	{
                GetPlayerScore(giveplayerid,gscore);
                GetPlayerScore(playerid,score);
		SetPlayerScore(giveplayerid,gscore+ amount);
		SetPlayerScore(playerid, score - amount);
		SendClientMessage(playerid, 0x00FF00AA, "Score sent");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Score received");
	}
	return 1;
}
not tested but i think it works
Reply
#4

I tried that, but for some reason it sets the score (of both the giver and the reciever) to 0... How can I change that?
Reply
#5

pawn Код:
dcmd_givescore(playerid, params[])
{
    new giveplayerid,
        amount,
        gscore = GetPlayerScore(playerid);
    if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /givescore [playerid/partname] [amount]");
    else if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else if(amount > gscore) return SendClientMessage(playerid, 0xFF0000AA, "Insufficient Score");
    else
    {
        SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) + amount);
        SetPlayerScore(playerid,gscore - amount);
        SendClientMessage(playerid, 0x00FF00AA, "Score sent");
        SendClientMessage(giveplayerid, 0x00FF00AA, "Score received");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)