Author Topic: playertype change function  (Read 5207 times)

Hey me and BlockAlpha are making a CS:GO server now we need the player to walk faster when he uses the knife and to have different animations so we made 2 playertypes, now i made the knife and i need to make the playertype change when he uses the knife how can i do that thanks for helpers ..

It's just %player.setDatablock("Datablock Name");

It's just %player.setDatablock("Datablock Name");
Isn't it the ID of the PlayerData datablock? (Remember that datablocks do not have spaces or certain special characters)

Isn't it the ID of the PlayerData datablock? (Remember that datablocks do not have spaces or certain special characters)

Giving the name or ID has no difference. If you try to run a method (or use a variable) on a string, it will try to find the object with that name.




function KarambitImage::onMount(%this, %obj, %slot)
{   
        %client.player.setDatablock(IDFSoldierK);
   %obj.hidenode("RHand");
}
 wont change my playertype


idk what you mean my coding knowledge is very weak please tell me how to fix it

The function does not know what %client is as you never mentioned it in the function before.
%obj already seems like it is pointing towards the player, so you don't need to know the client.
If you just change %client.player to %obj then it should work.

it doesn't work i get an error: Add-Ons/Weapon_Karambit/server.cs <237>: Unable to find object: ' '. Attemping to call function 'Set Datablock'

Did you change anything from
function KarambitImage::onMount(%this, %obj, %slot)
{   
        %client.player.setDatablock(IDFSoldierK);
   %obj.hidenode("RHand");
}

and if so, post the change.

Also, if I am not mistaken, you can point to client player with %this.player, unless I'm remembering my %this wrong.

Did you change anything from
and if so, post the change.

Also, if I am not mistaken, you can point to client player with %this.player, unless I'm remembering my %this wrong.

function KarambitImage::onMount(%this, %obj, %slot)
{   
        %obj.player.setDatablock(IDFSoldierK);
   %obj.hidenode("RHand");
}
 this is what i got atm

maybe the playertype name is wrong? how do i know what the playertype is called for the script ?

« Last Edit: December 23, 2014, 12:59:19 PM by portify »

%obj is already the player. You are trying to get the player from the player via %obj.player. Just refer to %obj directly.

Notice the error:

it doesn't work i get an error: Add-Ons/Weapon_Karambit/server.cs <237>: Unable to find object: ' '. Attemping to call function 'Set Datablock'

The object you're trying to call setDataBlock on does not exist.

function KarambitImage::onMount(%this, %obj, %slot)
                                       ^~~~ the object you're getting as an argument
...
        %obj.player.setDatablock(IDFSoldierK);
        ^~~~~~~~~~~ the object you're trying to call it on