SA-MP Forums Archive
[QUESTION] /skin - 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: [QUESTION] /skin (/showthread.php?tid=348479)



[QUESTION] /skin - mickos - 05.06.2012

Hey I have a question.
How do I create a skin script?
I mean, that if a player type ingame: / skin 170 that his skin turned into the skin 170.
That is of course logical.
But how do I create one so that players can choose ALL skins they want, so all the skins from 0 to 299.
And that the skin is also automatically saved.
And if an player disconnect and later again connect in the server, that he got his chosen skin ID,

Hopefully someone can help me.


Re: [QUESTION] /skin - doreto - 05.06.2012

go here - Script Request Thread or post her if you have any code were you have start or give any error


Re: [QUESTION] /skin - ViruZz - 05.06.2012

First for the making part you gotta use enum for example pSkin and when the players logins it will automatically detect the pSkin of the last saved skin.

But if I were you I'll start to learn how to script because this is a very basic thing and if we code this for you then you won't learn anything

****** or ******* couple Pawn Tutorial or Wiki's


Re: [QUESTION] /skin - mickos - 05.06.2012

Ahh, oke I dont need a map in my scriptfile for save the skin?


Re: [QUESTION] /skin - [NWA]Hannes - 05.06.2012

First you need something to save files, I recommend Dini, you can download the include here: http://*******/Lwnrbp
Put it in "SERVER\pawno\include" folder.

Then I just made this filterscript for you, it took me a while since im not very good with Dini, but I think I got it working: http://www.solidfiles.com/d/d29ce017fe/download/


Re: [QUESTION] /skin - ViruZz - 05.06.2012

Quote:
Originally Posted by [NWA]Hannes
Посмотреть сообщение
EDIT: Please give me +rep for this, as it was a little hard for me to make this
Just because you asked for it you don't deserve any.


Re: [QUESTION] /skin - mickos - 05.06.2012

I got this errors:

Quote:

C:\Users\Edward\Desktop\samp server 0.3e\pawno\saveskins.pwn(85) : error 047: array sizes do not match, or destination array is too small
C:\Users\Edward\Desktop\samp server 0.3e\pawno\saveskins.pwn(90) : error 047: array sizes do not match, or destination array is too small
C:\Users\Edward\Desktop\samp server 0.3e\pawno\saveskins.pwn(104) : error 021: symbol already defined: "strtok"
C:\Users\Edward\Desktop\samp server 0.3e\pawno\saveskins.pwn(119) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

This are the errors

Quote:

cmd = strtok(cmdtext, idx);

Quote:

tmp = strtok(cmdtext, idx);

Quote:

strtok(const string[], &index)
{

Quote:

return result;




Re: [QUESTION] /skin - mickos - 05.06.2012

this is de pwn code:

Quote:

//Created for BEER-samp at the sa-mp forums, by [NWA]Hannes, if you are using this please +rep me
#include <a_samp>
#include <Dini>

enum Saves
{
SavedSkin,
};
new Save[MAX_PLAYERS][Saves];

public OnFilterScriptExit()
{
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
new name[24];
new file[128];

GetPlayerName(i, name, sizeof(name));
format(file, sizeof(file), "SaveSkins/%s.ini", name);

if(!dini_Exists(file))
{
dini_Create(file);
}
else if(dini_Exists(file))
{
Save[i][SavedSkin] = dini_Int(file,"Skin");
}
}
}
return 1;
}

public OnPlayerConnect(playerid)
{
new name[24];
new file[128];

GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "SaveSkins/%s.ini", name);

if(!dini_Exists(file))
{
dini_Create(file);
}
else if(dini_Exists(file))
{
Save[playerid][SavedSkin] = dini_Int(file,"Skin");
}
return 1;
}

public OnPlayerDisconnect(playerid)
{
new file[128];
new name[24];

GetPlayerName(playerid, name, sizeof(name));
format(file, 100, "SaveSkins/%s.ini", name);

dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
return 1;
}

public OnPlayerSpawn(playerid)
{
new name[24];
new file[128];

GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "SaveSkins/%s.ini", name);

if(dini_Exists(file))
{
SetPlayerSkin(playerid, Save[playerid][SavedSkin]);
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/skin", true, 5)==0)
{
new tmp[128];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /skin [skin id]");
if(strval(tmp) < 300)
{
SetPlayerSkin(playerid, strval(tmp));
}
else SendClientMessage(playerid, 0xFF0000FF, "Error: Invalid skin id.");
return 1;
}
return 0;
}

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}




Re: [QUESTION] /skin - [NWA]Hannes - 05.06.2012

Quote:
Originally Posted by ViruZz
Посмотреть сообщение
Just because you asked for it you don't deserve any.
Yeah that was stupid of me, deleted that shit.


Quote:
Originally Posted by BEER-samp
Посмотреть сообщение
this is de pwn code:
EDIT: Nevermind that, do you have sscanf?


Re: [QUESTION] /skin - mickos - 05.06.2012

yes i got sscanf in my includes