SA-MP Forums Archive
String only shows first-letter. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: String only shows first-letter. (/showthread.php?tid=98362)



String only shows first-letter. - shitbird - 20.09.2009

Sup, i've got the commands working.. sort of.. now i just need one more tad of help...

If i do /cylinder <Kabuuu> it only shows: Cylinder: K. Anyone know whats wrong with it?

pawn Код:
dcmd_cylinder(playerid, params[])
{
    new
        string[128];
    if (sscanf(params, "s", string))
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/cylinder <cylinder name>\"");
        } else { ScooterCylinder[playerid] = params[playerid];
    }
    return 1;
}



Re: String only shows first-letter. - Nero_3D - 20.09.2009

the indention isnt good and the code doesnt make sense to me

just tell whats the command should do and what the array ScooterCylinder should store


Re: String only shows first-letter. - shitbird - 20.09.2009

Player uses /cylinder <cylinder name>
Player's Cylinder Stats becomes <cylinder name he had chosen>

i.e /checkcylinder <playerid>

"Player: Dude102's Cylinder is: <Cylinder name he had chosen>..

Get me?

Edit: don't mind the indentation, i'll fix that later .


Re: String only shows first-letter. - Nero_3D - 20.09.2009

first of all we need a 2d array to store a string for each player
pawn Код:
new ScooterCylinder[MAX_PLAYERS][MAX_PLAYER_NAME];
and than we store the text with the function format in ScooterCylinder
pawn Код:
dcmd_cylinder(playerid, params[])
    if(params[0] == EOS || strlen(params) >= sizeof(ScooterCylinder[]))
        return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/cylinder <cylinder name>\"");
    else    return format(ScooterCylinder[playerid], sizeof(ScooterCylinder[]), params);
and /checkcylinder need to look something like that
pawn Код:
dcmd_checkcylinder(playerid, params[])
{
    //some checks to get the playerid which was typed in (I call it now pid)
    new string[128];
    GetPlayerName(pid, string, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Player: %s's Cylinder is: %s..", string, ScooterCylinder[pid]);
    return SendClientMessage(playerid, 0xFFFFFFAA, string);
}



Re: String only shows first-letter. - shitbird - 20.09.2009

Ugh, i knew it wasnt correct, cheers mate..