SA-MP Forums Archive
SetPlayerVirtualWorld - 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: SetPlayerVirtualWorld (/showthread.php?tid=582462)



SetPlayerVirtualWorld - LeXuZ - 20.07.2015

Hello, I wanted to make a system where, if you are new, you will be put in a VirtualWorld, but I don't know how to keep changing the number, this is what I've got so far

Code:
new VW = 20;
pawn Code:
public OnPlayerSpawn(playerid)
{
    if (pInfo[playerid][Newbie] == 1)
    {
    new str[128];
    SetPlayerVirtualWorld(playerid, VW + 1);
    format(str, sizeof(str), "You are in VW %d", GetPlayerVirtualWorld(playerid));
    SendClientMessage(playerid, -1, str);
    }
    return 1;
}
can I have some help? thanks


Re: SetPlayerVirtualWorld - liquor - 20.07.2015

pawn Code:
// In OnPlayerSpawn
VW++;
SetPlayerVirtualWorld(playerid,VW);
There you go


Re: SetPlayerVirtualWorld - Sjn - 20.07.2015

SetPlayerVirtualWorld(playerid, playerid + 20);


Re: SetPlayerVirtualWorld - Beckett - 20.07.2015

pawn Code:
public OnPlayerSpawn(playerid)
{
    if(pInfo[playerid][Newbie] == 1)
    {
        //new str[128]; Why 128? you only need 20-30 max.
        new str[30],vw = GetPlayerVirtualWorld(playerid);
        SetPlayerVirtualWorld(playerid, vw + random(999));
        format(str, sizeof(str), "You are in VW %d.",vw); // Don't call the function GetPlayerVirtualWorld twice, you could call it once and assign it to a variable.
        SendClientMessage(playerid, -1, str);
    }
    return 1;
}



Re: SetPlayerVirtualWorld - liquor - 20.07.2015

Quote:
Originally Posted by DaniceMcHarley
View Post
pawn Code:
public OnPlayerSpawn(playerid)
{
    if(pInfo[playerid][Newbie] == 1)
    {
        //new str[128]; Why 128? you only need 20-30 max.
        new str[30],vw = GetPlayerVirtualWorld(playerid);
        SetPlayerVirtualWorld(playerid, vw + random(999));
        format(str, sizeof(str), "You are in VW %d.",vw); // Don't call the function GetPlayerVirtualWorld twice, you could call it once and assign it to a variable.
        SendClientMessage(playerid, -1, str);
    }
    return 1;
}
He didn't call he function twice, and you're at one point giving him advice to save processing, but on the other hand you're advicing him to add more processing (random). It doesn't have to be that hard.
Even my code were less efficient than Sjn's since I still had an integer, and his used 'playerid' which is already defined.

The only code he needs is playerid+whateverhewants and nobody else will get the same VW.


Re: SetPlayerVirtualWorld - SickAttack - 20.07.2015

Use a boolean instead of a whole integer number.

Quote:

if(variable) = true, if(!variable) = false

pawn Code:
public OnPlayerSpawn(playerid)
{
    if(pInfo[playerid][Newbie]) SetPlayerVirtualWorld(playerid, playerid);
    return 1;
}



Re: SetPlayerVirtualWorld - Beckett - 20.07.2015

Quote:
Originally Posted by liquor
View Post
He didn't call he function twice, and you're at one point giving him advice to save processing, but on the other hand you're advicing him to add more processing (random). It doesn't have to be that hard.
Even my code were less efficient than Sjn's since I still had an integer, and his used 'playerid' which is already defined.

The only code he needs is playerid+whateverhewants and nobody else will get the same VW.
Because his code was wrong from the first time. I didn't get him though you might be right because he did not elaborate correctly.


Re: SetPlayerVirtualWorld - LeXuZ - 20.07.2015

Thanks for the help guys!