[Tutorial] Making a simple command to set a player's data
#2

Quote:
Originally Posted by NealPeteros
View Post
In the beginning, we'll create a #define to define the max players. Put this on top of your script, but below the includes.
PHP Code:
#define MAX_PLAYERS 100 
You have to #undef MAX_PLAYERS first or else it'll cause problems.
PHP Code:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100 
Quote:
Originally Posted by NealPeteros
View Post
Put this on top of your script, but below the includes.
No, that's a huge mistake a lot of scripters make.
All the includes above the re-definition will use the default MAX_PLAYERS, which is 500.

You should always re-define MAX_PLAYERS under #include <a_samp>
PHP Code:
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
#include <sscanf2>
// #include ... 
Quote:
Originally Posted by NealPeteros
View Post
PHP Code:
if(sscanf(params"udd"giveplayeridamount)) 
There are only 2 parameters to enter (player's id/name and the level), so what's the use for the second "d"?
It's supposed to be "ud"


You should check if the player is connected or else the user can set INVALID_PLAYER_ID's level which would cause errors.
Because INVALID_PLAYER_ID > MAX_PLAYERS-1.

So, add this after the sscanf check:
PHP Code:
if (giveplayerid == INVALID_PLAYER_ID// We use that instead of IsPlayerConnected because sscanf2 automatically does that with "u"
    
return SendClientMessage(playerid, -1"Player is not connected."); 
By the way, you should mention the fact that this isn't a saving system.
A lot of new scripters that are looking for tutorials that teach how to make a registration system might get confused and think this is the same thing.
Reply


Messages In This Thread
Making a simple command to set a player's data - by NealPeteros - 21.08.2016, 15:31
Re: Making a simple command to set a player's data - by Stinged - 21.08.2016, 15:56
Re: Making a simple command to set a player's data - by NealPeteros - 21.08.2016, 16:03
Re: Making a simple command to set a player's data - by Logic_ - 22.08.2016, 12:06
Re: Making a simple command to set a player's data - by NealPeteros - 22.08.2016, 14:17
Re: Making a simple command to set a player's data - by Cerax101 - 29.08.2016, 04:47

Forum Jump:


Users browsing this thread: 1 Guest(s)