PDA

View Full Version : Getting playerdata


MattTucker
01/07/2017, 11:05 AM
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)

iLearner
01/07/2017, 11:56 AM
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.

MattTucker
01/07/2017, 12:24 PM
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!