02.01.2015, 22:17
why not advance that function so that we can tell it which character info we want
prints
now we just
getInfo(playerid,WhatTypeOfInfo)
whenever we need to and it'll always be the correct info
you dont really have to write 100 functions, just make one smarter and its done
youcould also set info that way:
simple, thats the cool ascpect of programming, we can make stuff smarter.
heck even create artificial intelligence if needed.
that way, we can let programs do stuff for us so that we have less to do ourselves
pawn Код:
#include "a_samp"
#define MAX_SLOTS (4)
enum c_info
{
bool: admin,
cash,
level
};
new CharacterInfo[MAX_PLAYERS][MAX_SLOTS][c_info];
new CurrentCharacter[MAX_PLAYERS];
public OnFilterScriptInit()
{
//imaging a player with the id 1
CurrentCharacter[1] = 3;
//lets set some stuff
CharacterInfo[1][CurrentCharacter[1]][admin] = true;
CharacterInfo[1][CurrentCharacter[1]][cash] = 500;
CharacterInfo[1][CurrentCharacter[1]][level] = 2;
//now we're using our smart "getInfo" to
//get the stuff we just set & print it
printf("is ID 1 admin? %s",(getInfo(1,admin) ? ("YES") : ("NO")));
printf("ID 1 - cash: %d",getInfo(1,cash));
printf("ID 1 - level: %d",getInfo(1,level));
return 1;
}
/**
* gets the info of the currect character
*
* @param playerid - simply the players ID
* @param type - the info we want
* @return The info, depending on type
* -------------------------------------
* Usage: new var = getInfo(playerid,info);
*/
getInfo(playerid,type)
{
return CharacterInfo[playerid][CurrentCharacter[playerid]][c_info:type];
}
Код:
----- Blank - Loaded! ----- Number of vehicle models: 0 loadfs smart is ID 1 admin? YES ID 1 - cash: 500 ID 1 - level: 2 Filterscript 'smart.amx' loaded.
getInfo(playerid,WhatTypeOfInfo)
whenever we need to and it'll always be the correct info

you dont really have to write 100 functions, just make one smarter and its done
youcould also set info that way:
pawn Код:
/**
* sets the info of the currect character
*
* @param playerid - simply the players ID
* @param type - the info we want to set
* @param value - the value assigned to type
* @return true on success
* -------------------------------------
* Usage: setInfo(playerid,info,40);
*/
setInfo(playerid,type,value)
{
//of course you have to think about if its a string or something... u know what i mean ;)
CharacterInfo[playerid][CurrentCharacter[playerid]][c_info:type] = value;
return true;//acknowledgement
}
heck even create artificial intelligence if needed.
that way, we can let programs do stuff for us so that we have less to do ourselves