Getting playerdata
#1

I wanted to try out the OOP idea and create a scratch gamemode for samp.
Basically I got
Код:
/* GAMEMODE FILES */
#include "minigames/playerdata.pwn"
#include "minigames/dialogs.pwn"
Playerdata has pInfo and such, however, I got this function to be able to access the variables from anywhere in the script
Код:
function GetPlayerInfo(playerid, pInfo:var)
{
	return PlayerInfo[playerid][var];
}
So the problem is, this function successfully returns the password of a player "inside" playerdata itself, however, when trying to use it in dialogs.pwn it turns into "1sers/-player name-.ini"

Dialogs.pwn code
Код:
			new tmpPass[60];
			format(tmpPass,sizeof(tmpPass), "%s", GetPlayerInfo(playerid,pPass));
			printf("%s general tmppass", tmpPass);
			printf("%s geenral getplayerinfo", GetPlayerInfo(playerid,pPass));
First printf shows the above
Second printf shows the same as tmpPass

Also, any ideas if I can better optimize it?

EDIT: tried using
Код:
if(strcmp(GetPlayerInfo(playerid,pPass), inputtext) == 0)
but shows an error
Код:
dialogs.pwn(41) : error 035: argument type mismatch (argument 1)
Reply
#2

No idea why you need the function while you can access them directly (PlayerInfo[playerid][pPass]).

anyway, in first and second print the passwords are same cause in first one you are formatting it and then showing it, while in second one you're showing it directly.
Reply
#3

Quote:
Originally Posted by iLearner
Посмотреть сообщение
No idea why you need the function while you can access them directly (PlayerInfo[playerid][pPass]).

anyway, in first and second print the passwords are same cause in first one you are formatting it and then showing it, while in second one you're showing it directly.
Is it possible to just use PlayerInfo[playerid][pPass] and such in other .pwns (not the main one I compile) without giving out errors?

EDIT: just tried it out. Thanks a lot mate!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)