[PROBLEM] Stopping a player to spawn with chosen skin? +Rep
#1

Good evening and hello to everyone, so Im facing this problem right now and I dont know what I did wrong, here it is:

So Im using this:

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) 
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == dizzlecar)
        {
          new pName[MAX_PLAYER_NAME];
          GetPlayerName(playerid,pName,sizeof(pName));
          if(strcmp(pName,"Dizzle") == 0)
		  {
           SendClientMessage(playerid,-1,"Welcome back!");
          }
          else
          {
          RemovePlayerFromVehicle(playerid);
          SendClientMessage(playerid,COLOR_ERROR,"You have the right to get out of Dizzle's car, punk!");
           }
        }
    }
to prevent players from using my car for example.

But when I use the same code under OnPlayerRequestSpawn to prevent players from spawning with my skin, it does nothing?
(Im locking them by this way cause I want to lock two same skin ids for different players)

Код:
public OnPlayerRequestSpawn(playerid)
{
    new SkinCheck = GetPlayerSkin(playerid);
    if(SkinCheck == dizzleskin)
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        if(strcmp(pName, "Dizzle", false) == 0)
        {
            SendClientMessage(playerid, 0x00FF00AA, "Welcome back!");
        }
        else
		{
        SendClientMessage(playerid, 0xFF0000AA, "This skin is locked for Dizzle only.");
        return 0;
        }
    }
I have added this also:
Код:
new dizzleskin;
and
Код:
dizzleskin=AddPlayerClass(blah blah my skin id and spawn pos etc.)
I've did it before and it was working, but since I stopped SA:MP for over a year I've forgotten many things, maybe Im forgotting something or it shouldn't be done this way ? Thanks in advance, everyone who atleast tries to help will get repped for sure!
Reply
#2

I recommend not even making the skin visible to the non-dizzle player.

Shit I forgot how the basic code looks like. But i think you can use an if statement and check the players name before the addclass line. Or, do not put it in the selection list and use a command for drizzle to change the skin.

Forgive me if I'm horribly wrong but this is my first post in like 5 years or so?
Reply
#3

The issue is that your adding "AddPlayerClass" to dizzleclass, and not the class ID. For instance, if your skin is 272 then I believe it should be IIRC:
pawn Код:
dizzleskin = 272;
Reply
#4

Thanks for replying but you dont get me

Im using this
Код:
dizzleskin=AddPlayerClass(blah blah my skin id and spawn pos etc.)
So I can lock the same skin ID then for another player too, like I want to lock skin id 19 for you and id 19 for me too:

Код:
dizzleskin=AddPlayerClass(19, spawn pos etc.)
Код:
abagailskin=AddPlayerClass(19, spawn pos etc.)
dizzle = 19; wont work cause if I lock it for me then if I do abagailskin = 19; it will mess up, get me ?

But anyway, +Repped for trying, if you got any other solution tell me, thanks both.
Reply
#5

I presume you should use that under OnPlayerRequestClass and if the class id is dizzleskin then you do your code.

Because if you do that under OnPlayerRequestClass you are filling the SkinCheck as "GetPlayerSkin" lets say the skin is 2, so SkinCheck = 2. if SkinCheck == dizzleskin which is a class id that's not possible because dizzleskin is not a skin id.

If you didn't understand yet tell me and I'll fill you with an example.
Reply
#6

Try this, if return OnPlayerRequestClass(playerid); won't work try to kill player.

Quote:

public OnPlayerSpawn(playerid)
{
new SkinCheck = GetPlayerSkin(playerid);
if(SkinCheck == dizzleskin)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
if(strcmp(pName, "Dizzle", false) == 0)
{
SendClientMessage(playerid, 0x00FF00AA, "Welcome back!");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "This skin is locked for Dizzle only. Try another one.");
return OnPlayerRequestClass(playerid);
}
}

Reply
#7

Hm I've tried locking the 1st skin in my skin selection (by my way) and it worked, but for the other skins isnt working ? Any solutions?
Reply
#8

If dizzleskin is a class, so why you are checking id via getplayerskin, lol. I think you are not understand your code.

And you should make class blocking in OnPlayerRequestClass.

Correct code:


Код:
public OnPlayerRequestClass(playerid,classid)
{
    if(classid == dizzleskin)
    {
        new pName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
		if(strcmp(pName, "Dizzle", false) == 0)
		{
			SendClientMessage(playerid, 0x00FF00AA, "Welcome back!");
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "This skin is locked for Dizzle only.");
			return 0;
		}
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)