drekes you should test your solutions before you post them...
Strings don't work with switch.
You have to use equal with ifs:
PHP Code:
if(equal(playerModel, "something1")){
}else if(equal(playerModel, "something2")){
}else if(equal(playerModel, "something3")){
//.....
or another option is to convert playerModel into number using some hashing function or storing number in a trie like this:
PHP Code:
#include <amxmodx>
#include <celltrie>
#include <cstrike>
new Trie:g_model_replacement_id
new g_custom_model[][] = {"model1", "model2", "model3", "model4"}
//cells:
// g_custom_model[0] equals "model1"
// g_custom_model[1] equals "model2"
// g_custom_model[2] equals "model3"
// g_custom_model[3] equals "model4"
// you can add more of them...
public plugin_init(){
g_model_replacement_id = TrieCreate()
//adding replacements
TrieSetCell(g_model_replacement_id, "terror", 0) //sets "model1" as a replacement for "terror"
TrieSetCell(g_model_replacement_id, "artic", 0) //sets "model1" as a replacement for "arctic"
TrieSetCell(g_model_replacement_id, "urban", 3) //sets "model4" as a replacement for "urban"
//....
}
public change_model(id){
static playerModel[32], model_id
cs_get_user_model(id, playerModel, 31)
if(!TrieGetCell(g_model_replacement_id, playerModel, model_id)){
return //model replacement has not been configured for retrieved playerModel
}
cs_set_user_model(id, g_custom_model[ model_id ])
//with replacements examples set in plugin_init
//if someone has "terror" or "arctic" then he will get "model1"
//if someone has "urban" then he will get "model4"
}
public plugin_end(){
TrieDestroy(g_model_replacement_id)
}
__________________