SA-MP Forums Archive
params ain't working. - 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)
+--- Thread: params ain't working. (/showthread.php?tid=433898)



params ain't working. - Black Axe - 30.04.2013

PHP код:
dcmd_createtele(playeridparams[])
{
    if( 
PlayerInfo[playerid][pAdmin] >= 1339)
    {
        new 
name[32], string[128];
        new 
idx GetFreeTeleSlot();
        if(
sscanf(params"s[32]"name)) return SendClientMessage(playeridX11_GREEN"USAGE: /createtele [name]");
        
GetPlayerPos(playeridTeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
        
GetPlayerFacingAngle(playeridTeleInfo[idx][tA]);
        
TeleInfo[idx][tVW] = GetPlayerVirtualWorld(playerid);
        
TeleInfo[idx][tInt] = GetPlayerInterior(playerid);
        
strmid(TeleInfo[idx][tName], name0strlen(name), 32);
        
format(stringsizeof(string), "Teleport Created: [Name: %s | ID: %d | X: %.02f | Y: %.02f | Z: %.02f | A: %.02f | VW: %d | Int: %d]",
        
TeleInfo[idx][tName], idxTeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ], TeleInfo[idx][tA], TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
        
SendClientMessage(playeridX11_ORANGEstring);
        
SaveTeleports();
    }
    else
    {
        
SendClientMessage(playeridX11_RED"ERROR: You are not authorized to use this command.");
    }
    return 
1;

As you see - This is the command.

However - When I type /createtele [any name] IG - It just shows /createtele [name]

Help would be appreciated.


Re: params ain't working. - L.Hudson - 30.04.2013

How about using this:

pawn Код:
dcmd_createtele(playerid, params[])
{
    if( PlayerInfo[playerid][pAdmin] >= 1339)
    {
        new id, string[128];
        new idx = GetFreeTeleSlot();
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, X11_GREEN, "USAGE: /createtele [name]");

        GetPlayerPos(playerid, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
        GetPlayerFacingAngle(playerid, TeleInfo[idx][tA]);
        TeleInfo[idx][tVW] = GetPlayerVirtualWorld(playerid);
        TeleInfo[idx][tInt] = GetPlayerInterior(playerid);
        strmid(TeleInfo[idx][tName], id, 0, strlen(id), 32);
        format(string, sizeof(string), "Teleport Created: [Name: %s | ID: %d | X: %.02f | Y: %.02f | Z: %.02f | A: %.02f | VW: %d | Int: %d]",
        TeleInfo[idx][tName], idx, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ], TeleInfo[idx][tA], TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
        SendClientMessage(playerid, X11_ORANGE, string);
        SaveTeleports();
    }
    else
    {
        SendClientMessage(playerid, X11_RED, "ERROR: You are not authorized to use this command.");
    }
    return 1;
}
What I did is to replace the param "s[32]" with "u" and changed new name[32] to new id; as the "u" param will get both the player's id and name.


Re: params ain't working. - JaKe Elite - 30.04.2013

Quote:
Originally Posted by L.Hudson
Посмотреть сообщение
How about using this:

pawn Код:
dcmd_createtele(playerid, params[])
{
    if( PlayerInfo[playerid][pAdmin] >= 1339)
    {
        new id, string[128];
        new idx = GetFreeTeleSlot();
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, X11_GREEN, "USAGE: /createtele [name]");

        GetPlayerPos(playerid, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
        GetPlayerFacingAngle(playerid, TeleInfo[idx][tA]);
        TeleInfo[idx][tVW] = GetPlayerVirtualWorld(playerid);
        TeleInfo[idx][tInt] = GetPlayerInterior(playerid);
        strmid(TeleInfo[idx][tName], id, 0, strlen(id), 32);
        format(string, sizeof(string), "Teleport Created: [Name: %s | ID: %d | X: %.02f | Y: %.02f | Z: %.02f | A: %.02f | VW: %d | Int: %d]",
        TeleInfo[idx][tName], idx, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ], TeleInfo[idx][tA], TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
        SendClientMessage(playerid, X11_ORANGE, string);
        SaveTeleports();
    }
    else
    {
        SendClientMessage(playerid, X11_RED, "ERROR: You are not authorized to use this command.");
    }
    return 1;
}
What I did is to replace the param "s[32]" with "u" and changed new name[32] to new id; as the "u" param will get both the player's id and name.


The command is not for player. So why you use u.

Anyway,
Do you've updated sscanf?


Re: params ain't working. - L.Hudson - 30.04.2013

He wanted to do it for a "name" and since he didn't use any saving like Dini or Y_INI in the command, I did "u" since the "u", as I said, gets both the player's name and ID.


Re: params ain't working. - RVRP - 30.04.2013

Hudson has a very valid point - if you are creating a command involving a player's ID (or name) which needs to be entered, use "u". Besides, you never called on the player's name after using it in the params. You could have used a string as the name of the player in the command, but you would have had to used 'name' in exchange of 'playerid' in the actions that the command enacts.

If this doesn't fix your problem please post again. You described the problem very vaguely so I'm not sure exactly what the issue is you are having - hopefully what he posted fixes it.