Team permission
#1

Hey everyone. I'm working on my own game mode but I need some help.

Well, I have this script for my PD team thingy.

public OnPlayerSpawn(playerid)
{
//pd skins
if(GetPlayerSkin(playerid) == 280)
SetPlayerColor(playerid,0x2641FEAA);


But I want that you need permission to choose this skin. And I also want that when the person logs in the next time
he will still have this permission. I don't mind if it is with rcon admin or something.
can someone make an example or something please?

REgards
Reply
#2

A basic exemple for you (Not Tested):

In your GM top:
pawn Код:
new bool:SkinPermission[MAX_PLAYERS];
In OnPlayerConnect:
pawn Код:
SkinPermission[playerid] = false;
In OnPlayerDisconnect:
pawn Код:
SkinPermission[playerid] = false;
In OnPlayerSpawn:
pawn Код:
SkinPermission[playerid] = false;
In OnPlayerRequestSpawn:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new Skin;
Skin = GetPlayerSkin(playerid);
if(Skin == 280)
{
if(SkinPermission[playerid] == false)
{
GameTextForPlayer(playerid,"~w~You not have ~r~permission!",3000,5);
return 0;
}
}
return 1;
}
And, In OnPlayerCommandText:
pawn Код:
new cmd[256],
    idx;

cmd = strtok(cmdtext, idx);
pawn Код:
if(strcmp(cmd, "/givepermission", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new tmp[128];
new giveplayerid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /givepermission [playerid]");
           
giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREEN, "Done!");
SkinPermission[giveplayerid] = true;
}
else if (!IsPlayerConnected(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREEN, "ERROR: Player not Conected!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "ERROR: You not is Administrator!");
}
return 1;
}
Reply
#3

When I put the stuff in OnPlayerCommandText it is giving errors

C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(443) : warning 225: unreachable code
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(443) : warning 217: loose indentation
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(446) : error 017: undefined symbol "strtok"
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(446) : error 033: array must be indexed (variable "cmd")
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(444) : warning 217: loose indentation
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(444 -- 44 : error 017: undefined symbol "cmd"
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(444 -- 44 : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.


new cmd[256],
idx;

cmd = strtok(cmdtext, idx);
}
if(strcmp(cmd, "/givepermission", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new tmp[128];
new giveplayerid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /givepermission [playerid]");

giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREEN, "Done!");
SkinPermission[giveplayerid] = true;
}
else if (!IsPlayerConnected(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREEN, "ERROR: Player not Conected!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "ERROR: You are not an Administrator!");
}
return 1;
}
Reply
#4

Put strtok in your GM/Fs:

pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= &#39; '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > &#39; ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#5

it is working now. But after I relog I lose the permission How can I change that to have permission for ever?
Reply
#6

You have to create a system to save into a file. So every time you enter, the server would read that file, if you had it authorization you can use the skin! I I recommend you to use dini!
Reply
#7

And can you tell me how to do that hm?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)