Question about a problem with a simple /setlevel command I made
#1

(First off, I'm new with scripting pawn so this might be a really easy fix, but I don't know) So I have an issue with my command. Basically the score is the character's level. I made a command called /setlevel that sets the users level up one. However, whenever I use /setlevel it won't go beyond one because I think it's setting the value to only 1. How can I fix this? I'll give the pawn code:

Код:
CMD:setlevel(playerid, params[])
{
    new playerlevel=0;
	playerlevel++;
	SetPlayerScore(playerid, playerlevel);
	SendClientMessage(playerid, COLOR_RED, "Your level has been set!");
	return 1;
}
Reply
#2

You can simply use something like that.
pawn Код:
CMD:setlevel(playerid,params[])
{
    SetPlayerScore(playerid,GetPlayerScore(playerid)+1); //getting the current player score and increase the value +1 , no need for all codes above.
    SendClientMessage(playerid, COLOR_RED, "Your level has been set!");
    return 1;
}
Sources :
https://sampwiki.blast.hk/wiki/SetPlayerScore
https://sampwiki.blast.hk/wiki/GetPlayerScore
Reply
#3

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
You can simply use something like that.
pawn Код:
CMD:setlevel(playerid,params[])
{
    SetPlayerScore(playerid,GetPlayerScore(playerid)+1); //getting the current player score and increase the value +1 , no need for all codes above.
    SendClientMessage(playerid, COLOR_RED, "Your level has been set!");
    return 1;
}
Sources :
https://sampwiki.blast.hk/wiki/SetPlayerScore
https://sampwiki.blast.hk/wiki/GetPlayerScore
Thanks that worked quite well for me. I didn't even know I could do something like that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)