Raised This Month: $51 Target: $400
 12% 

How to modify player skin ? for the next round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chakipic
Junior Member
Join Date: Jul 2008
Old 07-21-2008 , 14:49   How to modify player skin ? for the next round
Reply With Quote #1

Hello,

I would like to create a plugin for my server. I posted a request but nobody answered me :
http://forums.alliedmods.net/showthr...773#post655773

So, I would like to try to do it, but I will need your help to work fine

For the moment, I do that :

PHP Code:
#include <sourcemod>
#include <cstrike>

public Plugin:myinfo =
{
    
name "Chicken cut",
    
author "Me",
    
description "Transform a player who have been cut in chicken just for the next round"
    
version "1",
    
url ""
}


public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath)
}
 

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// I HAVE TO CHECK IF THE PLAYER WHO DIE WAS KILLED BY A KNIFE
    
if(GetEventInt(event"weapon") == "knife"){
        new 
victim_id GetEventInt(event"userid")
        new 
victim GetClientOfUserId(victim_id)


        
// I HAVE TO CREATE A FUNCTION TO TRANSFORM PLAYER IN CHICKEN JUST FOR THE NEXT ROUND
        // BY MODIFYING HIS SKIN


        // 1. IS THE PLAYER ALWAYS ONLINE BEFORE STARTING NEW ROUND ?
        // 2. IS THE CURRENT ROUND THE GOOD ROUND (ROUND AFTER CUTTING) ?
        //    MAYBE I COULD CREATE A TEMPORARY DATA AND USE IT TO CHECK IF PLAYER'S SKIN HAVE BEEN YET MODIFIED OR NOT ?
        // 3. IF ALL IS OK, HIS SKIN WILL BE CHANGE (IN CHICKEN) JUST FOR THE ROUND
        // 4. WHEN THE NEW ROUND IS FINISHED, OR A NEW MAP IS LAUNCHED, OR BECAUSE PLAYER DISCONNECT WE HAVE TO CHANGE PLAYER SKIN, WITH THE STANDARD SKIN
        //    SO I HAVE TO CLEAR THE TEMPORARY DATA WE CREATE AT THE POINT 2
    
}

As I never create Sourcemod plugin, I don't know differents functions I have to use.

It will be great if you could give me some advices/examples !

Thanks
chakipic is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-21-2008 , 14:58   Re: How to modify player skin ? for the next round
Reply With Quote #2

Hook the "player_spawn" event and use SetEntityModel.
bl4nk is offline
chakipic
Junior Member
Join Date: Jul 2008
Old 07-21-2008 , 16:38   Re: How to modify player skin ? for the next round
Reply With Quote #3

Thanks Bl4nk

I made a test... I try to transform immediatly in chicken, players who kill another one with "ak47".

I use the script below, and I try to compile it... and I have some errors :
PHP Code:
chicken.sp(21) : error 033: array must be indexed (variable "-unknown-")
chicken.sp(25) : error 017undefined symbol "SetEntityModel"
chicken.sp(23) : warning 204symbol is assigned a value that is never used"attacker" 
PHP Code:
#include <sourcemod>
#include <cstrike>

public Plugin:myinfo =
{
    
name "Chicken cut",
    
author "Me",
    
description "Transform a player who have been cut in chicken just for the next round",
    
version "1",
    
url ""
}

public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath)
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
GetEventInt(event"weapon") == "ak47"){
        new 
attacker_id GetEventInt(event"userid");
        new 
attacker GetClientOfUserId(attacker_id);

        
SetEntityModel(attacker,"models/chicken/chick.mdl");
    }

Can I use the condition "if(GetEventInt(event, "weapon") == "ak47"){" to know players who have to be transformed.
And how use exactly SetEntityModel

Thanks ! and sorry for all my questions
chakipic is offline
chakipic
Junior Member
Join Date: Jul 2008
Old 07-22-2008 , 08:59   Re: How to modify player skin ? for the next round
Reply With Quote #4

Someone could help me please ?
chakipic is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-22-2008 , 16:15   Re: How to modify player skin ? for the next round
Reply With Quote #5

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new bool:chicken[MAXPLAYERS+1];

public 
Plugin:myinfo =
{
    
name "Chicken cut",
    
author "Me",
    
description "Transform a player who have been cut in chicken just for the next round",
    
version "1",
    
url ""
}

public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));

    
decl String:weapon[32];
    
GetEventString(event"weapon"weaponsizeof(weapon));

    if(
strcmp(weapon"weapon_ak47") == 0)
    {
        
chicken[client] = true;
    }
}

public 
Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));

    if (
chicken[client])
    {
        
SetEntityModel(client,"models/chicken/chick.mdl");
        
chicken[client] = false;
    }

bl4nk is offline
chakipic
Junior Member
Join Date: Jul 2008
Old 07-22-2008 , 17:23   Re: How to modify player skin ? for the next round
Reply With Quote #6

Thanks bl4nk !

I tried your script and... I have no errors after compiling it.

And, in game, there is no change . Maybe the skin is not downloaded ?
I check my models folder in local and I don't find chicken skin's.

Last edited by chakipic; 07-22-2008 at 17:28.
chakipic is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-22-2008 , 18:11   Re: How to modify player skin ? for the next round
Reply With Quote #7

No clue. You might need to put it on a timer delay. I'd check to see if the model exists first though.
bl4nk is offline
TheDOO
Member
Join Date: Nov 2007
Old 07-22-2008 , 18:46   Re: How to modify player skin ? for the next round
Reply With Quote #8

Doesn't the model have to be precached? or added to the downloads table?
TheDOO is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-22-2008 , 18:53   Re: How to modify player skin ? for the next round
Reply With Quote #9

It does, but it should just give an error about late precaching it and still work.
bl4nk is offline
chakipic
Junior Member
Join Date: Jul 2008
Old 07-23-2008 , 08:22   Re: How to modify player skin ? for the next round
Reply With Quote #10

hlstriker had the same problem here :
http://forums.alliedmods.net/showthr...ownloads+table

And it is ok now, the skin is dowloaded in local.
I added it in the downloads table

Quote:
L 07/23/2008 - 13:25:05: -------- Mapchange to de_dust2 --------
L 07/23/2008 - 13:25:05: [chicken.smx] models/chicken/chick.mdl
L 07/23/2008 - 13:25:05: [chicken.smx] models/chicken/chick.mdl
L 07/23/2008 - 13:25:08: [chicken.smx] models/chicken/chick.mdl
L 07/23/2008 - 13:25:08: [chicken.smx] models/chicken/chick.mdl
It is located in counter-strike source > cstrike > models > chicken > chick.mdl

Then, I tried to kill someone with an ak47, and there is yet no change

Maybe the server don't recognize when someone is killed by an ak47 ?
Maybe we can't use this chicken skin's for CT or T ? I made tests with this skin :
http://www.fpsbanana.com/skins/687

I will try with another skin.
chakipic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode