strlen not working -
YouHack - 16.01.2017
In this cmd:
PHP код:
CMD:vipname(playerid, params[])
{
new text[10], szMessage[256];
new vehicleid = GetPlayerVehicleID(playerid);
if(sscanf(params, "s[50]", text)) return SCM(playerid, COLOR_WHITE, "SYNTAX: /vipname [name]");
if(PlayerInfo[playerid][pPremiumAccount] != 1) return SCM(playerid, COLOR_ERROR, "You don't have a premium account");
{
if(vText[playerid] != -1) return SCM(playerid, COLOR_WHITE, "Use first /removename to put another name on your car.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playerid, COLOR_WHITE, "You aren't in any car.");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SCM(playerid, COLOR_ERROR, "You aren't the driver.");
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 411) return SCM(playerid, COLOR_ERROR, "Car must be an Infernus in order to apply this command.");
if(OwnedVeh(vehicleid))
{
new maxc = strlen(text);
if(maxc > 10) return SCM(playerid,COLOR_WHITE,"{FFB870}Maximum caracters are 10.");
vText[playerid] = CreateObject(19327, -2597.0762, -2638.4270, -5.3536, -87.6999, 90.4001, -87.1805);
SetObjectMaterialText(vText[playerid] , text, 0, 50, "Arial", 15, 1, 0xFFFFFFFF, 0, 1);
AttachObjectToVehicle(vText[playerid] , vehicleid, 0.0,-1.9, 0.3, 270.0, 0.0, 0.0);
format(szMessage, sizeof(szMessage), "{F2CF09}Vipname is: '%s'", text);
SCM(playerid, COLOR_YELLOW, szMessage);
new var[356];
mysql_format(SQL, var, sizeof(var),"UPDATE `users` SET `vipnameinf`='%s' WHERE `name`='%s'", text, PlayerInfo[playerid][pNormalName]);
mysql_tquery(SQL, var,"","");
}
}
return 1;
}
Player can override 10 caracters,
also i want a query to load this text string onplayerlogin
Re: strlen not working -
azzerking - 16.01.2017
Issue:
Look at this line, you have the string size for 'text' set to the size of 10, yet in your sscanf function your telling it the string can fit the size of 50 in it?
Код:
if(sscanf(params, "s[50]", text)) return SCM(playerid, COLOR_WHITE, "SYNTAX: /vipname [name]"); // "s[50]" should be "s[10]"
There also no need to create a variable to hold the value of strlen, when you only use it once.
Also: Why are you checking if the strlen is more then 10 after everything else? Move it to after you call your sscanf function. However you don't even need to do that, since sscanf will cut off the text after 10.
Код:
if( strlen( text ) > 10 ) return SCM( playerid, COLOR_WHITE, "{FFB870}Maximum allowed characters are 10." ); // if you must use it
Re: strlen not working -
saffierr - 16.01.2017
Just do
PHP код:
if(strlen(text) > 10) // error message
You don't need to create a new variable for the strlen.
And for the Info: '<' = lower | '>' = higher
Re: strlen not working -
YouHack - 17.01.2017
oh thanks both,
and what about the mysql load query on player login?
Re: strlen not working -
MiiSha - 18.01.2017
Use Dini bro xD
Re: strlen not working -
azzerking - 19.01.2017
Quote:
Originally Posted by MiiSha
Use Dini bro xD
|
This is a help section, your input does not help the users at all, but instead suggesting he uses an old include when there are far more better ones available.
Please keep your witty remarks to yourself, or find another fitting section to post on.
Re: strlen not working -
Rufio - 19.01.2017
Quote:
Originally Posted by MiiSha
Use Dini bro xD
|
Dini? You must be kidding me. Why use Dini when there are 100x better INI processors? Not to even mention MySQL is superior in a lot of ways. Keep your remarks to yourself.
Can you elaborate on your question please? I am not sure if I understood what you wanted to do with the query.