Function related issue. -
SlayerHodge - 16.07.2018
Problem I am having a minor issue with a simple function, I created this function to: 1) check the PlayerInfo to see if the player's PhoneNumber is >1 thus printing to the function N/A. Else if the player has a phone number the function prints that number. The function is not printing or showing if the player doesnot have a number.
Код:
stock PlayerPhoneExist(playerid)
{
if(PlayerInfo[playerid][phonenumber]<1)
{
format(iStr,sizeof(iStr),"I/A");
print(iStr);
}
else
{
format(iStr,sizeof(iStr),"%d", PlayerInfo[playerid][phonenumber]);
print(iStr);
}
return 1;
}
how i plan on calling this function.
new istr;
format(istr, sizeof(istr), "%s %s" , RPNAME(playerid), GetPlayerPhoneExist(playerid)
SendClientmessage(playerid, COLOR_RED, istr);
please assist.
Re: Function related issue. -
IdonTmiss - 16.07.2018
U use "GetPlayerPhoneExist(playerid)"
Change it to
pawn Код:
PlayerPhoneExist(playerid);
Re: Function related issue. -
SlayerHodge - 17.07.2018
What? that would call the function and the function is not working.
it is an error in retyping, the function is hte issue, its not returning the Phone number or the I/A when the players number is less than 1
its giving it random numbers.
Re: Function related issue. -
Dayrion - 17.07.2018
Your code is no sense.
Firstly, PlayerPhoneExist return 1 no matter what happens in your function but the name let us understand that function need to be return 1 if the player's phone exist or 0 if not.
PHP код:
format(iStr,sizeof(iStr),"I/A");
print(iStr);
"iStr" doesn't exist in your function. In your example, you declare it as local variable and no, fortunately, as a global variable.
Re: Function related issue. -
SlayerHodge - 17.07.2018
thanks for your response, I had before this i had return iStr, iStr is a global array.
in functionality, i wanted to check the database for the playerinfo named phonenumber, depending on if it is below 1, it should print to the screen, N/A but in the other event that the Player info is = 0 or grater than 0 it should print the number stored in playerinfo Phonenumber, I am sorry for the confusion, i was just refferencing the function, in intirely i wanted to knpow if someone can alter it or assist me in producing the idea.
Re: Function related issue. -
GangstaSunny. - 17.07.2018
PHP код:
stock GetPlayerPhoneExist(playerid)
{
new number[24];
switch(PlayerInfo[playerid][phonenumber]);
{
case 0:{number="I/A";}
case 1..9999:{format(number,sizeof(number),"%d",PlayerInfo[playerid][phonenumber]);}
}
return number;
}
Give us some information about your (my)sql code if you want us to help you out with database loading stuff.
Re: Function related issue. -
GhostHacker9 - 17.07.2018
Quote:
Originally Posted by SlayerHodge
thanks for your response, I had before this i had return iStr, iStr is a global array.
in functionality, i wanted to check the database for the playerinfo named phonenumber, depending on if it is below 1, it should print to the screen, N/A but in the other event that the Player info is = 0 or grater than 0 it should print the number stored in playerinfo Phonenumber, I am sorry for the confusion, i was just refferencing the function, in intirely i wanted to knpow if someone can alter it or assist me in producing the idea.
|
wait what? 0 is less than 1 for your info
Re: Function related issue. -
Hreesang - 17.07.2018
Instead of confusing you (and my (and our)) mind, you might try this:
PHP код:
stock PlayerPhoneExist(playerid)
{
new
string[128]
;
if(PlayerInfo[playerid][phonenumber]<1)
{
format(string ,sizeof(string),"I/A");
print(string);
}
else
{
printf("%d", PlayerInfo[playerid][phonenumber]);
}
return 1;
}
Re: Function related issue. -
SlayerHodge - 17.07.2018
nah, solved the problem by myself, thanks though, i was not looking at something i had initializedd, I was placing a string variable in %d.
Код:
stock PlayerPhoneExist(playerid)
{
if(PlayerInfo[playerid][phonenumber]<1)
{
format(iStr,sizeof(iStr),"I/A");
printf(iStr);
}
else
{
format(iStr,sizeof(iStr),"%d", PlayerInfo[playerid][phonenumber]);
printf(iStr);
}
return iStr;
}