Variable shows no value
#1

So, basically. I have a system that counts player registeration.

Код:
     			new DBResult:Answer;
        		Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
        		db_get_field(Answer,0,string,sizeof(string));
    		    new name[MAX_PLAYER_NAME], string[256];
    			GetPlayerName(playerid, name, sizeof(name));
        		iUID = strval(string);
    			format(string, sizeof(string), "[NGF]%s Has successfully registered. Total Registered Accounts %d.", name, iUID);
       			SendClientMessageToAll(0xC4C4C4FF, string);
It shows "Total Registered Accounts 0"

When I remove the GetPlayerName thingy, it shows correct number of registered accounts. code is
Код:
   new DBResult:Answer;
        		Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
        		db_get_field(Answer,0,string,sizeof(string));
        		iUID = strval(string);
    			format(string, sizeof(string), "Total players %d.", iUID);
    			SendClientMessageToAll(0xC4C4C4FF, string);
So, how can I fix this.
Reply
#2

Код:
new DBResult:Answer;
        		Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
        		db_get_field(Answer,0,string,sizeof(string));//processing before declaration?
    		    new name[MAX_PLAYER_NAME], string[256];
    			GetPlayerName(playerid, name, sizeof(name));
        		iUID = strval(string);
    			format(string, sizeof(string), "[NGF]%s Has successfully registered. Total Registered Accounts %d.", name, iUID);
       			SendClientMessageToAll(0xC4C4C4FF, string);
You are processing the variable before declaration...
Reply
#3

I'm just a silly fuck.
it works, thanks a lot man... +2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)