Using (playerid == ) -
Josh_Main - 01.10.2014
Hey, I'm trying to create a PlayerLevel system but I'm having a little problem. If someone could teach me the difference between these 3 lines, that would be great! I just don't understand what the differences are between <=, >==. I also don't get the difference between one equals sign and two ( =, == ). Please help me out a little
pawn Код:
CMD:upgradelevel(playerid, params[])
{
new string[128];
GetPlayerScore(playerid);
if(GetPlayerScore(playerid <= 0) //this <=
if(GetPlayerScore(playerid == 0) //this ==
if(GetPlayerScore(playerid = 0) //this =
if(GetPlayerScore(playerid >= 0) //this >=
etc etc
I just want to know how I would make it so if the player is level 0 an they type /upgradelevel, it gives them level 2. If they type /upgradelevel when they're level 1, it makes them level 2 etc.
Also, what else would I have to add to make a level system? I've already added PlayerLevel under enums.
Thanks!!!!
Re: Using (playerid == ) -
Sawalha - 01.10.2014
> bigger than
< smaller than
>= bigger than OR equals
<= smaller than OR equals
== equals
EDIT: this link will help you more:
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
please explain more about level system so i can help you
Re: Using (playerid == ) -
Rudy_ - 01.10.2014
That? Here
https://sampwiki.blast.hk/wiki/Control_Structures#Operators
Re: Using (playerid == ) -
Josh_Main - 01.10.2014
Thank you both, I understand it a bit better now. But how would I do the /upgradelevel part? All I need to do is get the players level and +1 it
Re: Using (playerid == ) -
Dignity - 01.10.2014
pawn Код:
CMD:upgradelevel(playerid, params[])
{
// You close the "GetPlayerScore" function as it only returns a number.
// Check if it's equal to 0, and if it is...
if(GetPlayerScore(playerid) == 0)
{
// Give them +2 score, and add to their level variable.
SetPlayerScore(playerid, GetPlayerScore(playerid) + 2);
// pInfo[playerid][Level] += 2;
}
// Else, if level is equal to or higher than 2...
else if(GetPlayerScore(playerid) >= 2)
{
// Add only one level to their current score.
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
//pInfo[playerid][Level] ++; // And doing the same for their level variable.
}
// Returning a positive value.
return true;
}
Re: Using (playerid == ) -
Rudy_ - 01.10.2014
This is an example on how to do increase +1 lvl when a player types /upgradelevel
pawn Код:
CMD:upgradelevel(playerid, params[])
{
if(GetPlayerScore(playerid) >= 10) //if playerscore is equal or greater than 10
{
PlayerInfo[playerid][pLevel] = 2;
SendClientMessage(playerid, -1, "Gratz you're level 2");
}
if(GetPlayerScore(playerid) >= 20) //if playerscore is equal or greater than 20
{
PlayerInfo[playerid][pLevel] = 3;
SendClientMessage(playerid, -1, "Gratz you're level 3");
}
else return SendClientMessage(playerid, -1, "You dont have enough Score");
return 1;
}
You need to to have level system and in enums
Re: Using (playerid == ) -
Rudy_ - 01.10.2014
Edit: Sorry wanted to edit, double posted on mistake
This is an example on how to do increase +1 lvl when a player types /upgradelevel
pawn Код:
CMD:upgradelevel(playerid, params[])
{
if(GetPlayerScore(playerid) >= 10) //if playerscore is equal or greater than 10
{
PlayerInfo[playerid][pLevel] = 2;
SendClientMessage(playerid, -1, "Gratz you're level 2");
}
if(GetPlayerScore(playerid) >= 20) //if playerscore is equal or greater than 20
{
PlayerInfo[playerid][pLevel] = 3;
SendClientMessage(playerid, -1, "Gratz you're level 3");
}
else return SendClientMessage(playerid, -1, "You dont have enough Score");
return 1;
}
You need to to have level system and in enums
and i forgot
pawn Код:
public OnPlayerDeath(playerid, killerid)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
return 1;
}
Re: Using (playerid == ) -
Josh_Main - 01.10.2014
Thanks man!!
pawn Код:
public OnPlayerDeath(playerid, killerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
return 1;
}
But will this set the players level to 0 when they die? Just that I'm scripting a roleplay server so I want it to save the level
Re: Using (playerid == ) -
Dignity - 01.10.2014
Quote:
Originally Posted by Josh_Main
Thanks man!!
pawn Код:
public OnPlayerDeath(playerid, killerid) { SetPlayerScore(playerid, GetPlayerScore(playerid) + 1); return 1; }
But will this set the players level to 0 when they die? Just that I'm scripting a roleplay server so I want it to save the level 
|
No. Let's assume a player's level is 3. You set their score to their previous score (using GetPlayerScore); which would be three and then add 1 to that number which would make it 4.
Also, that code would give the player that died +1 score. If you want to give the killer +1 score, use "killerid" instead of "playerid".
Re: Using (playerid == ) -
Rudy_ - 01.10.2014
Quote:
Originally Posted by Mionee
No. Let's assume a player's level is 3. You set their score to their previous score (using GetPlayerScore); which would be three and then add 1 to that number which would make it 4.
Also, that code would give the player that died +1 score. If you want to give the killer +1 score, use "killerid" instead of "playerid".
|
yeah, i updated it soon after i found it out...