why dosnt this work?
#1

hum this just says ... has egoto disabled it dosnt teleport why?
pawn Код:
dcmd_enablegoto(playerid,params[])
{
    #pragma unused params
    enablegoto[playerid] = 1;
    return 1;
}
dcmd_egoto(playerid,params[])
{
    #pragma unused params
    new id,string[100],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME];
    if(enablegoto[id] == 0) return SendClientMessage(playerid,red,"ERROR: That player has goto disabled");
    GetPlayerPos(id,X,Y,Z);
    SetPlayerPos(playerid,X,Y,Z);
    GetPlayerName(id,pName2,sizeof(pName2));
    GetPlayerName(playerid,pName,sizeof(pName));
    format(string,sizeof(string),"||Teleported to %s||",pName2);
    SendClientMessage(playerid,grey,string);
    format(string,sizeof(string),"||%s has teleported to your position||",pName);
    SendClientMessage(id,grey,string);
    return 1;
}
no errors no warnings
Reply
#2

First of all, you do not use params, so the command is just /egoto without params. Use sscanf to make the params.
Reply
#3

You are making
pawn Код:
new id;
but you do not define it, zo "id" is always 0.
Reply
#4

sscanf: use this. It will be pretty simple to use. Please note you need the plugin or the code to use :P

Example:

pawn Код:
dcmd_me(playerid,params[])
{
    new text[128],Playername[MAX_PLAYER_NAME]; // will create a text string with 128 cells (= maximum) and a Playername with maximum name input.
    if(!sscanf(params,"s",text))
    {
        new string[128]; // will create a new string with 128 cells.
        GetPlayerName(playerid,Playername,sizeof(Playername)); // will get players name and store it in Playername.
        format(string,sizeof(string),"%s %s",Playername,text); // First %s = Playername... Second %d = text
        SendClientMessageToAll(COLOR_WHITE,string); // Sends the text!
    }
    else return SendClientMessage(playerid,COLOR_RED,"Syntax Error: /me 'text'."); // if the player did not type the things correctly.
    return 1;
}
I hope you do not mind my kind of identing. I think it's the best
Reply
#5

lol i made use sscanf more than u but i wanted to try without sscanf but i see i have no luck i have it with sccanf
Reply
#6

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
sscanf: use this. It will be pretty simple to use. Please note you need the plugin or the code to use :P

Example:

pawn Код:
dcmd_me(playerid,params[])
{
    new text[128],Playername[MAX_PLAYER_NAME]; // will create a text string with 128 cells (= maximum) and a Playername with maximum name input.
    if(!sscanf(params,"s",text))
    {
        new string[128]; // will create a new string with 128 cells.
        GetPlayerName(playerid,Playername,sizeof(Playername)); // will get players name and store it in Playername.
        format(string,sizeof(string),"%s %s",Playername,text); // First %s = Playername... Second %d = text
        SendClientMessageToAll(COLOR_WHITE,string); // Sends the text!
    }
    else return SendClientMessage(playerid,COLOR_RED,"Syntax Error: /me 'text'."); // if the player did not type the things correctly.
    return 1;
}
I hope you do not mind my kind of identing. I think it's the best
You don't even need sscanf for this command:

pawn Код:
dcmd_egoto(playerid,params[])
{
    new string[100], pName[25], pName2[25];
    if(!strlen(params)) return SendClientMessage(playerid,red,"USSAGE: /goto [id]");
    else if(enablegoto[id] == 0) return SendClientMessage(playerid,red,"ERROR: That player has goto disabled");
    else if(!IsPlayerConnected(strval(params))) return SendClientMessage(playerid,red,"Player not connected");
    else
    {
        GetPlayerPos(strval(params),X,Y,Z);
        SetPlayerPos(playerid,X,Y,Z);
        GetPlayerName(strval(params),pName2,25);
        GetPlayerName(playerid,25);
        format(string,100,"||Teleported to %s||",pName2);
        SendClientMessage(playerid,grey,string);
        format(string,100,"||%s has teleported to your position||",pName);
        SendClientMessage(strval(params),grey,string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)