Set Virtual world problem
#1

Hi, am new to samp forums and typically dont have a lot of internet access these days though am still highly interested in SAMP in general. So my problem comes when am working on a gamemode script trying to create a command that changes a players virtual world. The command works though when I enter the command as "/setvw [ID] 1" it returns a message saying changed virtual world to 1.0 which actually takes me to virtual world 10663244 so now am stuck trying to figure out where I went wrong and i'd your assistance.
Here's the command I made:
Код:
CMD:setvw(playerid, params[])
{
    //if(pInfo[playerid][AdminLvl] < 1) return -1;
    if(pInfo[playerid][AdminLvl] >= 7 || IsPlayerAdmin(playerid))
    {
        if(!pAdmDuty{playerid})
        {
            new targetid, str[100], VirtualWorld;
            if(sscanf(params, "uf", targetid, VirtualWorld)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setvw [ID] [VW]") ;
            if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "That player is not connected.") ;

            SetPlayerVirtualWorld(targetid, VirtualWorld);
            format(str, sizeof str, "*Admin %s has set %s's virtual world to %0.1f", pName[playerid], pName[targetid], VirtualWorld);
            SendAdminMessage(str);
        }
        else
        {
            return SendClientMessage(playerid, COLOR_RED, "You're not on admin duty.");
        }
    }
    else
    {
        return -1;
    }
    return 1;
}
Reply
#2

Virtual world value is not a float, its a simple integer.

use "ui" for the sscanf part and change %0.1f to %i.

and use /setvw 1 instead of /setvw 1.0

edit:
Код:
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "That player is not connected.") ;
I'm not sure if that will work. try this instead
Код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected.") ;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)