Simple /setskin cmd problem
#1

Hey,

I wonder maybe anyone could help newbie out. My problem is i wanted to transfer simple cmd from LA-RP to this GM
(( https://sampforum.blast.hk/showthread.php?tid=523030 )) How can i fix those errors?

Код:
	CMD:setskin(playerid, params[])
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "Kasuta: /setskin [MдngijaID/Osanimest] [Skinni ID]");
				return 1;
			}
			new para1;
			new level;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			level = strval(tmp);
			if(level > 299 || level < 1) { SendClientMessage(playerid, COLOR_WHITE, "Vale ID!"); return 1; }
   			if(PlayerData[playerid][AdminLevel] < 1)
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						PlayerInfo[para1][pChar] = level;
						format(string, sizeof(string), "Sinu skinn on vahetatud admin %s poolt", sendername);
						SendClientMessage(para1, COLOR_WHITE, string);
						format(string, sizeof(string), "Sa vahetasid mдngija %s skinni.", giveplayer);
						SendClientMessage(playerid, COLOR_WHITE, string);
					    SetPlayerSkin(para1, PlayerInfo[para1][pChar]);
					}
				}//not connected
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "   You'r not admin!!");
			}
		}
		return 1;
	}
Error's
Код:
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1040) : error 017: undefined symbol "tmp"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1040) : error 017: undefined symbol "strtok"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1041) : error 017: undefined symbol "tmp"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1043) : error 017: undefined symbol "COLOR_GRAD2"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1048) : error 017: undefined symbol "ReturnUser"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1049) : error 017: undefined symbol "tmp"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1049) : error 017: undefined symbol "strtok"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1050) : error 017: undefined symbol "tmp"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1051) : error 017: undefined symbol "COLOR_GREY"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1052) : error 017: undefined symbol "PlayerInfo"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1052) : warning 215: expression has no effect
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1052) : error 001: expected token: ";", but found "]"
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1052) : error 029: invalid expression, assumed zero
F:\Users\Kasutaja\Desktop\MySQL SA-MP server\gamemodes\fortcarson.pwn(1052) : fatal error 107: too many error messages on one line

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

Don't expect that it will compile (rare but it might) if copying-pasting codes. It's nice it gave you the error about strtok so you can avoid it from the beginning. It's very slow and outdated and you should really consider using sscanf.

pawn Код:
CMD:setskin(playerid, params[])
{
    // you can check if the player is admin and if not return an error message here..
    new userid, skinid;
    if (sscanf(params, "ri", userid, skinid)) return SendClientMessage(playerid, -1, "Kasuta: /setskin [MдngijaID/Osanimest] [Skinni ID]");
    if (!IsPlayerConnected(userid)) return SendClientMessage(playerid, -1, "Not connected");
    if (!(1 <= skinid <= 299) || skinid == 74) return SendClientMessage(playerid, -1, "Vale ID!");
    new szName1[MAX_PLAYER_NAME], szName2[MAX_PLAYER_NAME], szString[61];
    GetPlayerName(userid, szName1, MAX_PLAYER_NAME);
    GetPlayerName(playerid, szName2, MAX_PLAYER_NAME);
    format(szString, sizeof (szString), "Sinu skinn on vahetatud admin %s poolt", szName2);
    SendClientMessage(userid, -1, szString);
    format(szString, sizeof (szString), "Sa vahetasid mдngija %s skinni.", szName1);
    SendClientMessage(playerid, -1, szString);
    SetPlayerSkin(userid, skinid);
    // you can store the skinid to a variable here..
    return 1;
}
Reply
#3

Код:
CMD:setskin(playerid,params[])
{
	if(pInfo[playerid][pLevel] >= 1)
	{
        new id,skinid;
	    if(sscanf(params, "ui", id, skinid)) return
		SendClientMessage(playerid, yellow, "Usage: /Setskin <PlayerID> <skin ID>") ;
        if(IsPlayerConnected(id))
		{
            if(skinid < 0 || skinid > 299) return SendClientMessage(playerid, red, "Invaild Skin ID!");
            format(Jstring,sizeof(Jstring),"You have set %s's skin to %d", GetName(id), skinid);
			SendClientMessage(playerid,yellow,Jstring);
			format(Jstring, sizeof(Jstring), "Admin %s has given you a new skin (SkinID: %d)",GetName(playerid),skinid);
			SendClientMessage(id,lighterblue,Jstring);
			CommandToAdmins(playerid,"setskin");
   			return SetPlayerSkin(id, skinid);
	    }
		else return ShowMessage(playerid, red, 2);
	}
	else return ShowMessage(playerid, red, 1);
}
There you go.. just change it to your language
Reply
#4

Okey, thanks for correct cmd and help, but how can i store skin id's? Player skin id should save in my MySQL database.
Reply
#5

What do you mean ?

Explain little bit more
Reply
#6

Quote:
Originally Posted by YanLanger
Посмотреть сообщение
What do you mean ?

Explain little bit more
Sorry.
I mean when player change his skin this should save to her stats in my MySQL database. After /restart or logout player still have CJ skin.
Reply
#7

Hmmm

Try to go to users and open Playername.ini or whatever and add Skin = SKIN ID

I am NOT sure this will work !

Maybe :P
Reply
#8

I think this way will work, but i want that if you change skin ingame and this skinID will save.
Reply
#9

ye just do what i did :P

If worked +rep me xD
Reply
#10

Quote:
Originally Posted by YanLanger
Посмотреть сообщение
ye just do what i did :P

If worked +rep me xD
Lol u want just rep -__
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)