params ain't working.
#1

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.
Reply
#2

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.
Reply
#3

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?
Reply
#4

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.
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)