setname cmd
#1

Allright so I was trying to do a simple setname cmd with zcmd and sscanf im new in this and I got confused in the first part so here is the code

Код:
CMD:setacc(playerid, params[])
{
	new newname[24];
        new userplayerid;
	if(sscanf(params,"u", userplayerid))return SendClientMessage(playerid, 0x33CC33,"USAGE:/setacc [accname]");
	if(sscanf(params,"s", newname))return SendClientMessageToAll(playerid, 0x33CC33,"(GetPlayerName) has changed his account name to %s");
	return SetPlayerName (playerid, newname);
	
}
It gives me the error
Код:
C:\Documents and Settings\Administrador\Ambiente de trabalho\samp03x_svr_R1-2_win32\pawno\strapz.pwn(483) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Anybody knows how to fix?Im just trying simple cmds
Reply
#2

pawn Код:
CMD:setacc(playerid, params[])
{
    // variables
    new newname[24], oldname[24], userplayerid, string[128];
   
    // checks if parameters are filled
    if(sscanf(params, "us[24]", userplayerid, newname)) return SendClientMessage(playerid, 0x33CC33FF, "USAGE: /setacc [playerid] [accname]");

    GetPlayerName(userplayerid, oldname, 24); // stores the old name
   
    format(string, sizeof(string), "%s has changed his account name to %s", oldname, newname); // message to show
    SendClientMessageToAll(0x33CC33FF, string); // sends message to all players
    SetPlayerName(userplayerid, newname); // changes the player's name to the new name
   
    return 1;
}
That should work.
Reply
#3

What exactly are you trying to achieve with this /setname command? Is it:

Код:
/setname [Player ID/ Part of name] [New name]
That? If so:

pawn Код:
CMD:setacc(playerid, params[])
{
    new newname[24];
    new userplayerid;
    if(sscanf(params,"us[24]", userplayerid, newname))return SendClientMessage(playerid, 0x33CC33,"USAGE:/setname [Player ID/ Part of name] [New name]");
    return SetPlayerName (userplayerid, newname);  
}
You will learn more on how to use sscanf/command processor here.
Reply
#4

project man, i am a fucking noob with scripting i realy dont understand how and i think u are good, so can u please make a command with /setname for me?
Reply
#5

Quote:
Originally Posted by Saffier
Посмотреть сообщение
project man, i am a fucking noob with scripting i realy dont understand how and i think u are good, so can u please make a command with /setname for me?
Just a simple one:
pawn Код:
CMD:setname(playerid, params[])
{
    new id, name[24];
   
    if(sscanf(params, "us[24]", id, name))
        return SendClientMessage(playerid, -1, "SYNTAX: /setname [playerid/PartOfName] [name]");
       
    SetPlayerName(id, name);
    return 1;
}
Reply
#6

Quote:
Originally Posted by Saffier
Посмотреть сообщение
project man, i am a fucking noob with scripting i realy dont understand how and i think u are good, so can u please make a command with /setname for me?
Quote:
Originally Posted by ProjectMan
Посмотреть сообщение
What exactly are you trying to achieve with this /setname command? Is it:

Код:
/setname [Player ID/ Part of name] [New name]
That? If so:

pawn Код:
CMD:setacc(playerid, params[])
{
    new newname[24];
    new userplayerid;
    if(sscanf(params,"us[24]", userplayerid, newname))return SendClientMessage(playerid, 0x33CC33,"USAGE:/setname [Player ID/ Part of name] [New name]");
    return SetPlayerName (userplayerid, newname);  
}
You will learn more on how to use sscanf/command processor here.
Read that... Especially the bold part.
Reply
#7

so skribbelz if i copy that and compile it i have that in my server? or something else needed?
Reply
#8

Quote:
Originally Posted by Saffier
Посмотреть сообщение
so skribbelz if i copy that and compile it i have that in my server? or something else needed?
So long as you have sscanf and ZCMD, read ProjectMan's post and check out the link.
Reply
#9

projectman you're /setname cmd has 1error

C:\Users\Laka\Desktop\Test Server\pawno\setname cmd.pwn(1 --8 ) : error 013: no entry point (no public functions)
Reply
#10

Quote:
Originally Posted by Saffier
Посмотреть сообщение
projectman you're /setname cmd has 1error

C:\Users\Laka\Desktop\Test Server\pawno\setname cmd.pwn(1 --8 ) : error 013: no entry point (no public functions)
Well, I'm going to assume you opened up Pawno (in a totally empty workspace) and put that code in and compiled the code. That is not how scripting works. This will help you out..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)